Fix PostgreSQL broadcast column upgrade, make some changes to followup message handling
This commit is contained in:
parent
a67c2b9884
commit
fa3d7b3772
3 changed files with 22 additions and 8 deletions
|
@ -8,7 +8,7 @@ const psqlUpdates = [
|
|||
"", // reserved
|
||||
"CREATE TABLE IF NOT EXISTS settings ( id smallint PRIMARY KEY, version integer NOT NULL, CHECK(id = 1) );\nALTER TABLE guilds ADD COLUMN accessed timestamp;",
|
||||
"ALTER TABLE guilds DROP COLUMN accessed",
|
||||
"ALTER TABLE settings ADD COLUMN broadcast text"
|
||||
"ALTER TABLE settings ADD COLUMN IF NOT EXISTS broadcast text"
|
||||
];
|
||||
|
||||
export async function setup() {
|
||||
|
|
|
@ -65,8 +65,8 @@ export default async (client, info, pages, timeout = 120000) => {
|
|||
if (info.type === "classic") {
|
||||
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 ? "editOriginal" : "createMessage"](Object.assign(pages[page], pages.length > 1 ? components : {}));
|
||||
currentPage = await info.interaction.getOriginal();
|
||||
currentPage = await info.interaction[info.interaction.acknowledged ? "editOriginal" : "createMessage"](Object.assign(pages[page], pages.length > 1 ? components : {}));
|
||||
if (!currentPage) currentPage = await info.interaction.getOriginal();
|
||||
}
|
||||
|
||||
if (pages.length > 1) {
|
||||
|
|
|
@ -141,8 +141,14 @@ 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 ? "editOriginal" : "createMessage"](content);
|
||||
playingMessage = await options.interaction.getOriginal();
|
||||
if ((Date.now() - options.interaction.createdAt) >= 900000) { // discord interactions are only valid for 15 minutes
|
||||
playingMessage = await client.rest.channels.createMessage(options.channel.id, content);
|
||||
} else if (lastTrack && lastTrack !== track) {
|
||||
playingMessage = await options.interaction.createFollowup(content);
|
||||
} else {
|
||||
playingMessage = await options.interaction[options.interaction.acknowledged ? "editOriginal" : "createMessage"](content);
|
||||
if (!playingMessage) playingMessage = await options.interaction.getOriginal();
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
|
@ -206,7 +212,11 @@ export async function nextSong(client, options, connection, track, info, music,
|
|||
if (options.type === "classic") {
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createFollowup({ content });
|
||||
if ((Date.now() - options.interaction.createdAt) >= 900000) {
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createFollowup({ content });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
|
@ -240,7 +250,7 @@ export async function errHandle(exception, client, connection, playingMessage, v
|
|||
} catch {
|
||||
// no-op
|
||||
}
|
||||
if (closed) connection.removeAllListeners("exception");
|
||||
connection.removeAllListeners("exception");
|
||||
connection.removeAllListeners("stuck");
|
||||
connection.removeAllListeners("end");
|
||||
try {
|
||||
|
@ -248,7 +258,11 @@ export async function errHandle(exception, client, connection, playingMessage, v
|
|||
if (options.type === "classic") {
|
||||
await client.rest.channels.createMessage(playingMessage.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createFollowup({ content });
|
||||
if ((Date.now() - options.interaction.createdAt) >= 900000) {
|
||||
await client.rest.channels.createMessage(options.channel.id, { content });
|
||||
} else {
|
||||
await options.interaction.createFollowup({ content });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
|
|
Loading…
Reference in a new issue