Fix playing statuses, fix large image posting, fix music slash command
This commit is contained in:
parent
49a60bba96
commit
d68ff19e4d
4 changed files with 31 additions and 23 deletions
|
@ -10,7 +10,7 @@ class MusicAIOCommand extends Command {
|
||||||
if (this.type === "classic") {
|
if (this.type === "classic") {
|
||||||
this.origOptions.args.shift();
|
this.origOptions.args.shift();
|
||||||
} else {
|
} else {
|
||||||
this.origOptions.interaction.data.options = this.origOptions.interaction.data.options[0].options;
|
this.origOptions.interaction.data.options.raw = this.origOptions.interaction.data.options.raw[0].options;
|
||||||
}
|
}
|
||||||
if (aliases.has(cmd)) cmd = aliases.get(cmd);
|
if (aliases.has(cmd)) cmd = aliases.get(cmd);
|
||||||
if (commands.has(cmd) && info.get(cmd).category === "music") {
|
if (commands.has(cmd) && info.get(cmd).category === "music") {
|
||||||
|
|
|
@ -55,8 +55,8 @@ export function textEncode(string) {
|
||||||
export async function activityChanger(bot) {
|
export async function activityChanger(bot) {
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
await bot.editStatus("dnd", [{
|
await bot.editStatus("dnd", [{
|
||||||
type: "GAME",
|
type: 0,
|
||||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
setTimeout(() => activityChanger(bot), 900000);
|
setTimeout(() => activityChanger(bot), 900000);
|
||||||
|
@ -70,16 +70,16 @@ export function checkBroadcast(bot) {
|
||||||
|
|
||||||
export function startBroadcast(bot, message) {
|
export function startBroadcast(bot, message) {
|
||||||
bot.editStatus("dnd", [{
|
bot.editStatus("dnd", [{
|
||||||
type: "GAME",
|
type: 0,
|
||||||
name: message + (types.classic ? ` | @${bot.user.username} help` : ""),
|
name: message + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||||
}]);
|
}]);
|
||||||
broadcast = true;
|
broadcast = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function endBroadcast(bot) {
|
export function endBroadcast(bot) {
|
||||||
bot.editStatus("dnd", [{
|
bot.editStatus("dnd", [{
|
||||||
type: "GAME",
|
type: 0,
|
||||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||||
}]);
|
}]);
|
||||||
broadcast = false;
|
broadcast = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,8 +159,8 @@ export async function nextSong(client, options, connection, track, info, music,
|
||||||
if (options.type === "classic") {
|
if (options.type === "classic") {
|
||||||
playingMessage = await client.rest.channels.createMessage(options.channel.id, content);
|
playingMessage = await client.rest.channels.createMessage(options.channel.id, content);
|
||||||
} else {
|
} else {
|
||||||
await options.interaction[options.interaction.acknowledged ? "editOriginalMessage" : "createMessage"](content);
|
await options.interaction[options.interaction.acknowledged ? "editOriginal" : "createMessage"](content);
|
||||||
playingMessage = await options.interaction.getOriginalMessage();
|
playingMessage = await options.interaction.getOriginal();
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// no-op
|
// no-op
|
||||||
|
@ -190,11 +190,15 @@ export async function nextSong(client, options, connection, track, info, music,
|
||||||
players.delete(voiceChannel.guildID);
|
players.delete(voiceChannel.guildID);
|
||||||
queues.delete(voiceChannel.guildID);
|
queues.delete(voiceChannel.guildID);
|
||||||
logger.error(exception.error);
|
logger.error(exception.error);
|
||||||
|
try {
|
||||||
const content = `🔊 Looks like there was an error regarding sound playback:\n\`\`\`${exception.type}: ${exception.error}\`\`\``;
|
const content = `🔊 Looks like there was an error regarding sound playback:\n\`\`\`${exception.type}: ${exception.error}\`\`\``;
|
||||||
if (options.type === "classic") {
|
if (options.type === "classic") {
|
||||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||||
} else {
|
} else {
|
||||||
await options.interaction.createMessage({ content });
|
await options.interaction.createFollowup({ content });
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connection.on("stuck", () => {
|
connection.on("stuck", () => {
|
||||||
|
@ -243,11 +247,15 @@ export async function nextSong(client, options, connection, track, info, music,
|
||||||
players.delete(voiceChannel.guildID);
|
players.delete(voiceChannel.guildID);
|
||||||
queues.delete(voiceChannel.guildID);
|
queues.delete(voiceChannel.guildID);
|
||||||
skipVotes.delete(voiceChannel.guildID);
|
skipVotes.delete(voiceChannel.guildID);
|
||||||
|
try {
|
||||||
const content = `🔊 The voice channel session in \`${voiceChannel.name}\` has ended.`;
|
const content = `🔊 The voice channel session in \`${voiceChannel.name}\` has ended.`;
|
||||||
if (options.type === "classic") {
|
if (options.type === "classic") {
|
||||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||||
} else {
|
} else {
|
||||||
await options.interaction.createMessage({ content });
|
await options.interaction.createFollowup({ content });
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.type === "classic") {
|
if (options.type === "classic") {
|
||||||
|
|
|
@ -5,7 +5,7 @@ let dirSizeCache;
|
||||||
|
|
||||||
export async function upload(client, result, context, interaction = false) {
|
export async function upload(client, result, context, interaction = false) {
|
||||||
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
|
const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`;
|
||||||
await writeFile(`${process.env.TEMPDIR}/${filename}`, result.file);
|
await writeFile(`${process.env.TEMPDIR}/${filename}`, result.contents);
|
||||||
const imageURL = `${process.env.TMP_DOMAIN || "https://tmp.projectlounge.pw"}/${filename}`;
|
const imageURL = `${process.env.TMP_DOMAIN || "https://tmp.projectlounge.pw"}/${filename}`;
|
||||||
const payload = {
|
const payload = {
|
||||||
embeds: [{
|
embeds: [{
|
||||||
|
@ -21,7 +21,7 @@ export async function upload(client, result, context, interaction = false) {
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
if (interaction) {
|
if (interaction) {
|
||||||
await context[context.acknowledged ? "editOriginalMessage" : "createMessage"](payload);
|
await context[context.acknowledged ? "editOriginal" : "createMessage"](payload);
|
||||||
} else {
|
} else {
|
||||||
await client.rest.channels.createMessage(context.channel.id, Object.assign(payload, {
|
await client.rest.channels.createMessage(context.channel.id, Object.assign(payload, {
|
||||||
messageReference: {
|
messageReference: {
|
||||||
|
@ -36,7 +36,7 @@ export async function upload(client, result, context, interaction = false) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (process.env.THRESHOLD) {
|
if (process.env.THRESHOLD) {
|
||||||
const size = dirSizeCache + result.file.length;
|
const size = dirSizeCache + result.contents.length;
|
||||||
dirSizeCache = size;
|
dirSizeCache = size;
|
||||||
await removeOldImages(size);
|
await removeOldImages(size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue