Initial Oceanic port (still unfinished), update packages, remove serverinfo and userinfo
This commit is contained in:
parent
bf90ae108a
commit
888f2f8b4a
49 changed files with 573 additions and 515 deletions
|
@ -118,16 +118,16 @@ export async function enableCommand(guild, command) {
|
|||
}
|
||||
|
||||
export async function disableChannel(channel) {
|
||||
const guildDB = await this.getGuild(channel.guild.id);
|
||||
await sql`UPDATE guilds SET disabled_commands = ${[...guildDB.disabled, channel.id]} WHERE guild_id = ${channel.guild.id}`;
|
||||
disabledCache.set(channel.guild.id, [...guildDB.disabled, channel.id]);
|
||||
const guildDB = await this.getGuild(channel.guildID);
|
||||
await sql`UPDATE guilds SET disabled_commands = ${[...guildDB.disabled, channel.id]} WHERE guild_id = ${channel.guildID}`;
|
||||
disabledCache.set(channel.guildID, [...guildDB.disabled, channel.id]);
|
||||
}
|
||||
|
||||
export async function enableChannel(channel) {
|
||||
const guildDB = await this.getGuild(channel.guild.id);
|
||||
const guildDB = await this.getGuild(channel.guildID);
|
||||
const newDisabled = guildDB.disabled.filter(item => item !== channel.id);
|
||||
await sql`UPDATE guilds SET disabled_commands = ${newDisabled} WHERE guild_id = ${channel.guild.id}`;
|
||||
disabledCache.set(channel.guild.id, newDisabled);
|
||||
await sql`UPDATE guilds SET disabled_commands = ${newDisabled} WHERE guild_id = ${channel.guildID}`;
|
||||
disabledCache.set(channel.guildID, newDisabled);
|
||||
}
|
||||
|
||||
export async function getCounts() {
|
||||
|
|
|
@ -106,16 +106,16 @@ export async function enableCommand(guild, command) {
|
|||
}
|
||||
|
||||
export async function disableChannel(channel) {
|
||||
const guildDB = await this.getGuild(channel.guild.id);
|
||||
connection.prepare("UPDATE guilds SET disabled = ? WHERE guild_id = ?").run(JSON.stringify([...JSON.parse(guildDB.disabled), channel.id]), channel.guild.id);
|
||||
collections.disabledCache.set(channel.guild.id, [...JSON.parse(guildDB.disabled), channel.id]);
|
||||
const guildDB = await this.getGuild(channel.guildID);
|
||||
connection.prepare("UPDATE guilds SET disabled = ? WHERE guild_id = ?").run(JSON.stringify([...JSON.parse(guildDB.disabled), channel.id]), channel.guildID);
|
||||
collections.disabledCache.set(channel.guildID, [...JSON.parse(guildDB.disabled), channel.id]);
|
||||
}
|
||||
|
||||
export async function enableChannel(channel) {
|
||||
const guildDB = await this.getGuild(channel.guild.id);
|
||||
const guildDB = await this.getGuild(channel.guildID);
|
||||
const newDisabled = JSON.parse(guildDB.disabled).filter(item => item !== channel.id);
|
||||
connection.prepare("UPDATE guilds SET disabled = ? WHERE guild_id = ?").run(JSON.stringify(newDisabled), channel.guild.id);
|
||||
collections.disabledCache.set(channel.guild.id, newDisabled);
|
||||
connection.prepare("UPDATE guilds SET disabled = ? WHERE guild_id = ?").run(JSON.stringify(newDisabled), channel.guildID);
|
||||
collections.disabledCache.set(channel.guildID, newDisabled);
|
||||
}
|
||||
|
||||
export async function getTag(guild, tag) {
|
||||
|
|
|
@ -122,9 +122,9 @@ export async function send(bot) {
|
|||
log("info", "Sending application command data to Discord...");
|
||||
let cmdArray = commandArray.main;
|
||||
if (process.env.ADMIN_SERVER && process.env.ADMIN_SERVER !== "") {
|
||||
await bot.bulkEditGuildCommands(process.env.ADMIN_SERVER, commandArray.private);
|
||||
await bot.application.bulkEditGuildCommands(process.env.ADMIN_SERVER, commandArray.private);
|
||||
} else {
|
||||
cmdArray = [...commandArray.main, ...commandArray.private];
|
||||
}
|
||||
await bot.bulkEditCommands(cmdArray);
|
||||
await bot.application.bulkEditGlobalCommands(cmdArray);
|
||||
}
|
|
@ -131,8 +131,8 @@ const checkImages = async (message, extraReturnTypes, video, sticker) => {
|
|||
}
|
||||
}
|
||||
// then check the attachments
|
||||
} else if (message.attachments.length !== 0 && message.attachments[0].width) {
|
||||
type = await getImage(message.attachments[0].proxy_url, message.attachments[0].url, video);
|
||||
} else if (message.attachments.size !== 0 && message.attachments.first().width) {
|
||||
type = await getImage(message.attachments.first().proxyURL, message.attachments.first().url, video);
|
||||
}
|
||||
}
|
||||
// if the return value exists then return it
|
||||
|
@ -147,7 +147,7 @@ export default async (client, cmdMessage, interaction, options, extraReturnTypes
|
|||
if (options) {
|
||||
if (options.image) {
|
||||
const attachment = interaction.data.resolved.attachments.get(options.image);
|
||||
const result = await getImage(attachment.proxyUrl, attachment.url, video, attachment.contentType);
|
||||
const result = await getImage(attachment.proxyURL, attachment.url, video, attachment.contentType);
|
||||
if (result !== false) return result;
|
||||
} else if (options.link) {
|
||||
const result = await getImage(options.link, options.link, video, extraReturnTypes, false, null, true);
|
||||
|
@ -171,7 +171,8 @@ export default async (client, cmdMessage, interaction, options, extraReturnTypes
|
|||
if (!singleMessage) {
|
||||
// if there aren't any replies or interaction attachments then iterate over the last few messages in the channel
|
||||
try {
|
||||
const messages = await client.getMessages((interaction ? interaction : cmdMessage).channel.id);
|
||||
const channel = (interaction ? interaction : cmdMessage).channel ?? await client.rest.channels.get((interaction ? interaction : cmdMessage).channelID);
|
||||
const messages = await channel.getMessages();
|
||||
// iterate over each message
|
||||
for (const message of messages) {
|
||||
const result = await checkImages(message, extraReturnTypes, video, sticker);
|
||||
|
@ -180,7 +181,7 @@ export default async (client, cmdMessage, interaction, options, extraReturnTypes
|
|||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
|
|
@ -52,11 +52,12 @@ export function textEncode(string) {
|
|||
}
|
||||
|
||||
// set activity (a.k.a. the gamer code)
|
||||
export function activityChanger(bot) {
|
||||
export async function activityChanger(bot) {
|
||||
if (!broadcast) {
|
||||
bot.editStatus("dnd", {
|
||||
await bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
});
|
||||
}]);
|
||||
}
|
||||
setTimeout(() => activityChanger(bot), 900000);
|
||||
}
|
||||
|
@ -68,16 +69,18 @@ export function checkBroadcast(bot) {
|
|||
}
|
||||
|
||||
export function startBroadcast(bot, message) {
|
||||
bot.editStatus("dnd", {
|
||||
bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: message + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
});
|
||||
}]);
|
||||
broadcast = true;
|
||||
}
|
||||
|
||||
export function endBroadcast(bot) {
|
||||
bot.editStatus("dnd", {
|
||||
bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
});
|
||||
}]);
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
|
@ -107,4 +110,47 @@ export function getServers(bot) {
|
|||
resolve(bot.guilds.size);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// copied from eris
|
||||
export function cleanMessage(message) {
|
||||
let cleanContent = message.content && message.content.replace(/<a?(:\w+:)[0-9]+>/g, "$1") || "";
|
||||
|
||||
let authorName = message.author.username;
|
||||
if (message.guildID) {
|
||||
const member = message.guild.members.get(message.author.id);
|
||||
if (member && member.nick) {
|
||||
authorName = member.nick;
|
||||
}
|
||||
}
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${message.author.id}>`, "g"), `@\u200b${authorName}`);
|
||||
|
||||
if (message.mentions) {
|
||||
for (const mention of message.mentions.members) {
|
||||
if (message.guildID) {
|
||||
const member = message.guild.members.get(mention.id);
|
||||
if (member && member.nick) {
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${mention.id}>`, "g"), `@\u200b${member.nick}`);
|
||||
}
|
||||
}
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@!?${mention.id}>`, "g"), `@\u200b${mention.username}`);
|
||||
}
|
||||
|
||||
if (message.guildID && message.mentions.roles) {
|
||||
for (const roleID of message.mentions.roles) {
|
||||
const role = message.guild.roles.get(roleID);
|
||||
const roleName = role ? role.name : "deleted-role";
|
||||
cleanContent = cleanContent.replace(new RegExp(`<@&${roleID}>`, "g"), `@\u200b${roleName}`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of message.mentions.channels) {
|
||||
const channel = message.client.getChannel(id);
|
||||
if (channel && channel.name && channel.mention) {
|
||||
cleanContent = cleanContent.replace(channel.mention, `#${channel.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cleanContent.replace(/@everyone/g, "@\u200beveryone").replace(/@here/g, "@\u200bhere");
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// eris doesn't come with a method to wait for interactions by default, so we make our own
|
||||
// oceanic doesn't come with a method to wait for interactions by default, so we make our own
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
class InteractionCollector extends EventEmitter {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import InteractionCollector from "./awaitinteractions.js";
|
||||
import { ComponentInteraction } from "eris";
|
||||
import { ComponentInteraction } from "oceanic.js";
|
||||
|
||||
export default async (client, info, pages, timeout = 120000) => {
|
||||
const options = info.type === "classic" ? {
|
||||
messageReference: {
|
||||
channelID: info.channel.id,
|
||||
channelID: info.message.channelID,
|
||||
messageID: info.message.id,
|
||||
guildID: info.channel.guild ? info.channel.guild.id : undefined,
|
||||
guildID: info.message.guildID,
|
||||
failIfNotExists: false
|
||||
},
|
||||
allowedMentions: {
|
||||
|
@ -26,7 +26,7 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
name: "◀"
|
||||
},
|
||||
style: 1,
|
||||
custom_id: "back"
|
||||
customID: "back"
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
|
@ -36,7 +36,7 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
name: "▶"
|
||||
},
|
||||
style: 1,
|
||||
custom_id: "forward"
|
||||
customID: "forward"
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
|
@ -46,7 +46,7 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
name: "🔢"
|
||||
},
|
||||
style: 1,
|
||||
custom_id: "jump"
|
||||
customID: "jump"
|
||||
},
|
||||
{
|
||||
type: 2,
|
||||
|
@ -56,24 +56,24 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
name: "🗑"
|
||||
},
|
||||
style: 4,
|
||||
custom_id: "delete"
|
||||
customID: "delete"
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
let currentPage;
|
||||
if (info.type === "classic") {
|
||||
currentPage = await client.createMessage(info.message.channel.id, Object.assign(pages[page], options, pages.length > 1 ? components : {}));
|
||||
currentPage = await client.rest.channels.createMessage(info.message.channelID, Object.assign(pages[page], options, pages.length > 1 ? components : {}));
|
||||
} else {
|
||||
await info.interaction[info.interaction.acknowledged ? "editOriginalMessage" : "createMessage"](Object.assign(pages[page], pages.length > 1 ? components : {}));
|
||||
currentPage = await info.interaction.getOriginalMessage();
|
||||
await info.interaction[info.interaction.acknowledged ? "editOriginal" : "createMessage"](Object.assign(pages[page], pages.length > 1 ? components : {}));
|
||||
currentPage = await info.interaction.getOriginal();
|
||||
}
|
||||
|
||||
if (pages.length > 1) {
|
||||
const interactionCollector = new InteractionCollector(client, currentPage, ComponentInteraction, timeout);
|
||||
interactionCollector.on("interaction", async (interaction) => {
|
||||
if ((interaction.member ?? interaction.user).id === info.author.id) {
|
||||
switch (interaction.data.custom_id) {
|
||||
switch (interaction.data.customID) {
|
||||
case "back":
|
||||
await interaction.deferUpdate();
|
||||
page = page > 0 ? --page : pages.length - 1;
|
||||
|
@ -99,7 +99,7 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
type: 1,
|
||||
components: [{
|
||||
type: 3,
|
||||
custom_id: "seekDropdown",
|
||||
customID: "seekDropdown",
|
||||
placeholder: "Page Number",
|
||||
options: []
|
||||
}]
|
||||
|
@ -114,11 +114,11 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
}
|
||||
var promise;
|
||||
if (info.type === "classic") {
|
||||
promise = client.createMessage(info.message.channel.id, Object.assign({ content: "What page do you want to jump to?" }, {
|
||||
promise = client.rest.channels.createMessage(info.message.channelID, Object.assign({ content: "What page do you want to jump to?" }, {
|
||||
messageReference: {
|
||||
channelID: currentPage.channel.id,
|
||||
channelID: currentPage.channelID,
|
||||
messageID: currentPage.id,
|
||||
guildID: currentPage.channel.guild ? currentPage.channel.guild.id : undefined,
|
||||
guildID: currentPage.guildID,
|
||||
failIfNotExists: false
|
||||
},
|
||||
allowedMentions: {
|
||||
|
@ -132,9 +132,9 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
const dropdownCollector = new InteractionCollector(client, askMessage, ComponentInteraction, timeout);
|
||||
let ended = false;
|
||||
dropdownCollector.on("interaction", async (response) => {
|
||||
if (response.data.custom_id !== "seekDropdown") return;
|
||||
if (response.data.customID !== "seekDropdown") return;
|
||||
try {
|
||||
if (askMessage.channel.messages ? askMessage.channel.messages.has(askMessage.id) : await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
|
||||
await askMessage.delete();
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
dropdownCollector.once("end", async () => {
|
||||
if (ended) return;
|
||||
try {
|
||||
if (askMessage.channel.messages ? askMessage.channel.messages.has(askMessage.id) : await client.getMessage(askMessage.channel.id, askMessage.id).catch(() => undefined)) await askMessage.delete();
|
||||
await askMessage.delete();
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
@ -159,7 +159,11 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
case "delete":
|
||||
await interaction.deferUpdate();
|
||||
interactionCollector.emit("end", true);
|
||||
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) await currentPage.delete();
|
||||
try {
|
||||
await currentPage.delete();
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
@ -172,8 +176,10 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
for (const index of components.components[0].components.keys()) {
|
||||
components.components[0].components[index].disabled = true;
|
||||
}
|
||||
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) {
|
||||
try {
|
||||
await currentPage.edit(components);
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ export async function checkStatus() {
|
|||
}
|
||||
|
||||
export function connect(client) {
|
||||
manager = new Shoukaku(new Connectors.Eris(client), nodes, { moveOnDisconnect: true, resume: true, reconnectInterval: 500, reconnectTries: 1 });
|
||||
manager = new Shoukaku(new Connectors.OceanicJS(client), nodes, { moveOnDisconnect: true, resume: true, reconnectInterval: 500, reconnectTries: 1 });
|
||||
client.emit("ready"); // workaround
|
||||
manager.on("error", (node, error) => {
|
||||
logger.error(`An error occurred on Lavalink node ${node}: ${error}`);
|
||||
|
@ -66,7 +66,7 @@ export async function play(client, sound, options, music = false) {
|
|||
if (!options.channel.guild.permissionsOf(client.user.id).has("voiceConnect")) return { content: "I can't join this voice channel!", flags: 64 };
|
||||
const voiceChannel = options.channel.guild.channels.get(options.member.voiceState.channelID);
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return { content: "I don't have permission to join this voice channel!", flags: 64 };
|
||||
if (!music && manager.players.has(options.channel.guild.id)) return { content: "I can't play a sound effect while other audio is playing!", flags: 64 };
|
||||
if (!music && manager.players.has(options.channel.guildID)) return { content: "I can't play a sound effect while other audio is playing!", flags: 64 };
|
||||
let node = manager.getNode();
|
||||
if (!node) {
|
||||
const status = await checkStatus();
|
||||
|
@ -87,17 +87,17 @@ export async function play(client, sound, options, music = false) {
|
|||
logger.error(e);
|
||||
return { content: "🔊 Hmmm, seems that all of the audio servers are down. Try again in a bit.", flags: 64 };
|
||||
}
|
||||
const oldQueue = queues.get(voiceChannel.guild.id);
|
||||
const oldQueue = queues.get(voiceChannel.guildID);
|
||||
if (!response.tracks || response.tracks.length === 0) return { content: "I couldn't find that song!", flags: 64 };
|
||||
if (music) {
|
||||
const sortedTracks = response.tracks.map((val) => { return val.track; });
|
||||
const playlistTracks = response.playlistInfo.selectedTrack ? sortedTracks : [sortedTracks[0]];
|
||||
queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, ...playlistTracks] : playlistTracks);
|
||||
queues.set(voiceChannel.guildID, oldQueue ? [...oldQueue, ...playlistTracks] : playlistTracks);
|
||||
}
|
||||
const playerMeta = players.get(options.channel.guild.id);
|
||||
const playerMeta = players.get(options.channel.guildID);
|
||||
let player;
|
||||
if (node.players.has(voiceChannel.guild.id)) {
|
||||
player = node.players.get(voiceChannel.guild.id);
|
||||
if (node.players.has(voiceChannel.guildID)) {
|
||||
player = node.players.get(voiceChannel.guildID);
|
||||
} else if (playerMeta?.player) {
|
||||
const storedState = playerMeta?.player?.connection.state;
|
||||
if (storedState && storedState === 1) {
|
||||
|
@ -105,7 +105,7 @@ export async function play(client, sound, options, music = false) {
|
|||
}
|
||||
}
|
||||
const connection = player ?? await node.joinChannel({
|
||||
guildId: voiceChannel.guild.id,
|
||||
guildId: voiceChannel.guildID,
|
||||
channelId: voiceChannel.id,
|
||||
shardId: voiceChannel.guild.shard.id,
|
||||
deaf: true
|
||||
|
@ -120,19 +120,19 @@ export async function play(client, sound, options, music = false) {
|
|||
}
|
||||
|
||||
export async function nextSong(client, options, connection, track, info, music, voiceChannel, host, loop = false, shuffle = false, lastTrack = null) {
|
||||
skipVotes.delete(voiceChannel.guild.id);
|
||||
skipVotes.delete(voiceChannel.guildID);
|
||||
const parts = Math.floor((0 / info.length) * 10);
|
||||
let playingMessage;
|
||||
if (music && lastTrack === track && players.has(voiceChannel.guild.id)) {
|
||||
playingMessage = players.get(voiceChannel.guild.id).playMessage;
|
||||
if (music && lastTrack === track && players.has(voiceChannel.guildID)) {
|
||||
playingMessage = players.get(voiceChannel.guildID).playMessage;
|
||||
} else {
|
||||
try {
|
||||
const content = !music ? "🔊 Playing sound..." : {
|
||||
const content = !music ? { content: "🔊 Playing sound..." } : {
|
||||
embeds: [{
|
||||
color: 16711680,
|
||||
author: {
|
||||
name: "Now Playing",
|
||||
icon_url: client.user.avatarURL
|
||||
iconURL: client.user.avatarURL
|
||||
},
|
||||
fields: [{
|
||||
name: "ℹ️ Title",
|
||||
|
@ -157,7 +157,7 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
}]
|
||||
};
|
||||
if (options.type === "classic") {
|
||||
playingMessage = await client.createMessage(options.channel.id, content);
|
||||
playingMessage = await client.rest.channels.createMessage(options.channel.id, content);
|
||||
} else {
|
||||
await options.interaction[options.interaction.acknowledged ? "editOriginalMessage" : "createMessage"](content);
|
||||
playingMessage = await options.interaction.getOriginalMessage();
|
||||
|
@ -171,30 +171,30 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
connection.removeAllListeners("end");
|
||||
connection.setVolume(0.70);
|
||||
connection.playTrack({ track });
|
||||
players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: host, voiceChannel: voiceChannel, originalChannel: options.channel, loop, shuffle, playMessage: playingMessage });
|
||||
players.set(voiceChannel.guildID, { player: connection, type: music ? "music" : "sound", host: host, voiceChannel: voiceChannel, originalChannel: options.channel, loop, shuffle, playMessage: playingMessage });
|
||||
connection.once("exception", async (exception) => {
|
||||
try {
|
||||
if (playingMessage.channel.messages.has(playingMessage.id)) await playingMessage.delete();
|
||||
const playMessage = players.get(voiceChannel.guild.id).playMessage;
|
||||
const playMessage = players.get(voiceChannel.guildID).playMessage;
|
||||
if (playMessage.channel.messages.has(playMessage.id)) await playMessage.delete();
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
try {
|
||||
connection.node.leaveChannel(voiceChannel.guild.id);
|
||||
connection.node.leaveChannel(voiceChannel.guildID);
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
connection.removeAllListeners("stuck");
|
||||
connection.removeAllListeners("end");
|
||||
players.delete(voiceChannel.guild.id);
|
||||
queues.delete(voiceChannel.guild.id);
|
||||
players.delete(voiceChannel.guildID);
|
||||
queues.delete(voiceChannel.guildID);
|
||||
logger.error(exception.error);
|
||||
const content = `🔊 Looks like there was an error regarding sound playback:\n\`\`\`${exception.type}: ${exception.error}\`\`\``;
|
||||
if (options.type === "classic") {
|
||||
await client.createMessage(options.channel.id, content);
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createMessage(content);
|
||||
await options.interaction.createMessage({ content });
|
||||
}
|
||||
});
|
||||
connection.on("stuck", () => {
|
||||
|
@ -204,11 +204,11 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
});
|
||||
connection.on("end", async (data) => {
|
||||
if (data.reason === "REPLACED") return;
|
||||
let queue = queues.get(voiceChannel.guild.id);
|
||||
const player = players.get(voiceChannel.guild.id);
|
||||
let queue = queues.get(voiceChannel.guildID);
|
||||
const player = players.get(voiceChannel.guildID);
|
||||
if (player && process.env.STAYVC === "true") {
|
||||
player.type = "idle";
|
||||
players.set(voiceChannel.guild.id, player);
|
||||
players.set(voiceChannel.guildID, player);
|
||||
}
|
||||
let newQueue;
|
||||
if (player?.shuffle) {
|
||||
|
@ -225,7 +225,7 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
} else {
|
||||
newQueue = queue ? queue.slice(1) : [];
|
||||
}
|
||||
queues.set(voiceChannel.guild.id, newQueue);
|
||||
queues.set(voiceChannel.guildID, newQueue);
|
||||
if (newQueue.length !== 0) {
|
||||
const newTrack = await connection.node.rest.decode(newQueue[0]);
|
||||
nextSong(client, options, connection, newQueue[0], newTrack, music, voiceChannel, host, player.loop, player.shuffle, track);
|
||||
|
@ -239,15 +239,15 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
}
|
||||
} else if (process.env.STAYVC !== "true") {
|
||||
await setTimeout(400);
|
||||
connection.node.leaveChannel(voiceChannel.guild.id);
|
||||
players.delete(voiceChannel.guild.id);
|
||||
queues.delete(voiceChannel.guild.id);
|
||||
skipVotes.delete(voiceChannel.guild.id);
|
||||
connection.node.leaveChannel(voiceChannel.guildID);
|
||||
players.delete(voiceChannel.guildID);
|
||||
queues.delete(voiceChannel.guildID);
|
||||
skipVotes.delete(voiceChannel.guildID);
|
||||
const content = `🔊 The voice channel session in \`${voiceChannel.name}\` has ended.`;
|
||||
if (options.type === "classic") {
|
||||
await client.createMessage(options.channel.id, content);
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createMessage(content);
|
||||
await options.interaction.createMessage({ content });
|
||||
}
|
||||
}
|
||||
if (options.type === "classic") {
|
||||
|
|
|
@ -23,11 +23,11 @@ export async function upload(client, result, context, interaction = false) {
|
|||
if (interaction) {
|
||||
await context[context.acknowledged ? "editOriginalMessage" : "createMessage"](payload);
|
||||
} else {
|
||||
await client.createMessage(context.channel.id, Object.assign(payload, {
|
||||
await client.rest.channels.createMessage(context.channel.id, Object.assign(payload, {
|
||||
messageReference: {
|
||||
channelID: context.channel.id,
|
||||
messageID: context.id,
|
||||
guildID: context.channel.guild ? context.channel.guild.id : undefined,
|
||||
guildID: context.channel.guildID ?? undefined,
|
||||
failIfNotExists: false
|
||||
},
|
||||
allowedMentions: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue