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") {
|
||||
this.origOptions.args.shift();
|
||||
} 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 (commands.has(cmd) && info.get(cmd).category === "music") {
|
||||
|
|
|
@ -55,8 +55,8 @@ export function textEncode(string) {
|
|||
export async function activityChanger(bot) {
|
||||
if (!broadcast) {
|
||||
await bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
type: 0,
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||
}]);
|
||||
}
|
||||
setTimeout(() => activityChanger(bot), 900000);
|
||||
|
@ -70,16 +70,16 @@ export function checkBroadcast(bot) {
|
|||
|
||||
export function startBroadcast(bot, message) {
|
||||
bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: message + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
type: 0,
|
||||
name: message + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||
}]);
|
||||
broadcast = true;
|
||||
}
|
||||
|
||||
export function endBroadcast(bot) {
|
||||
bot.editStatus("dnd", [{
|
||||
type: "GAME",
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : ""),
|
||||
type: 0,
|
||||
name: random(messages) + (types.classic ? ` | @${bot.user.username} help` : "")
|
||||
}]);
|
||||
broadcast = false;
|
||||
}
|
||||
|
|
|
@ -159,8 +159,8 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
if (options.type === "classic") {
|
||||
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();
|
||||
await options.interaction[options.interaction.acknowledged ? "editOriginal" : "createMessage"](content);
|
||||
playingMessage = await options.interaction.getOriginal();
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
|
@ -190,11 +190,15 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
players.delete(voiceChannel.guildID);
|
||||
queues.delete(voiceChannel.guildID);
|
||||
logger.error(exception.error);
|
||||
try {
|
||||
const content = `🔊 Looks like there was an error regarding sound playback:\n\`\`\`${exception.type}: ${exception.error}\`\`\``;
|
||||
if (options.type === "classic") {
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createMessage({ content });
|
||||
await options.interaction.createFollowup({ content });
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
connection.on("stuck", () => {
|
||||
|
@ -243,11 +247,15 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
players.delete(voiceChannel.guildID);
|
||||
queues.delete(voiceChannel.guildID);
|
||||
skipVotes.delete(voiceChannel.guildID);
|
||||
try {
|
||||
const content = `🔊 The voice channel session in \`${voiceChannel.name}\` has ended.`;
|
||||
if (options.type === "classic") {
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createMessage({ content });
|
||||
await options.interaction.createFollowup({ content });
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
if (options.type === "classic") {
|
||||
|
|
|
@ -5,7 +5,7 @@ let dirSizeCache;
|
|||
|
||||
export async function upload(client, result, context, interaction = false) {
|
||||
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 payload = {
|
||||
embeds: [{
|
||||
|
@ -21,7 +21,7 @@ export async function upload(client, result, context, interaction = false) {
|
|||
}]
|
||||
};
|
||||
if (interaction) {
|
||||
await context[context.acknowledged ? "editOriginalMessage" : "createMessage"](payload);
|
||||
await context[context.acknowledged ? "editOriginal" : "createMessage"](payload);
|
||||
} else {
|
||||
await client.rest.channels.createMessage(context.channel.id, Object.assign(payload, {
|
||||
messageReference: {
|
||||
|
@ -36,7 +36,7 @@ export async function upload(client, result, context, interaction = false) {
|
|||
}));
|
||||
}
|
||||
if (process.env.THRESHOLD) {
|
||||
const size = dirSizeCache + result.file.length;
|
||||
const size = dirSizeCache + result.contents.length;
|
||||
dirSizeCache = size;
|
||||
await removeOldImages(size);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue