Skip to content

Commit

Permalink
fix: use correct query to get queues from DB, adjust fallback to not …
Browse files Browse the repository at this point in the history
…delete queues if message or channel cant be found on normal interaction
  • Loading branch information
maybeanerd committed Jun 1, 2023
1 parent 2986756 commit 105a901
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/commands/queue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,18 @@ export async function goToNextUser(
if (wentToNextUser) {
const channel = await guild.channels.fetch(wentToNextUser.channelId);
if (!channel) {
// We should only get here if we cannot access the channel anymore
// and therefore we should end the queue
await endRunningQueue(interaction);
return;
throw new Error(
`Failed to get channel of queue message. GuildId: ${guild.id}; ChannelId: ${wentToNextUser.channelId}`,
);
}

const topicMessage = await (channel as TextChannel).messages.fetch(
wentToNextUser.messageId,
);
if (!topicMessage) {
// We should only get here if we cannot find the original message anymore
// and therefore we should end the queue
await endRunningQueue(interaction);
return;
throw new Error(
`Failed to get queue message. GuildId: ${guild.id}; ChannelId: ${wentToNextUser.channelId}; MessageId: ${wentToNextUser.messageId}`,
);
}

messageEdit(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/queue/stateManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OngoingQueue, OngoingQueueModel } from '../../db';

async function getQueue(guildId: string) {
return OngoingQueueModel.findOne({ where: { guildId } });
return OngoingQueueModel.findOne({ guildId });
}

function getActiveUserOfQueue(queue: OngoingQueue) {
Expand Down

0 comments on commit 105a901

Please sign in to comment.