Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct query to get queues from DB, adjust fallback to not delete queues if message or channel cant be found on normal interaction #835

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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