jsw
jsw
DIAdiscord.js - Imagine an app
Created by jsw on 12/29/2024 in #djs-questions
Bot crashes: invalid webhook token
Hi my bot crashes after running a command that takes about 15 minutes to finish? The command updates the message according to the 'game state'. this is the error code
error: Uncaught (in promise) DiscordAPIError[50027]: Invalid Webhook Token
at handleErrors (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:727:13)
at eventLoopTick (ext:core/01_core.js:175:7)
at async SequentialHandler.runRequest (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:1128:23)
at async SequentialHandler.queueRequest (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:959:14)
at async _REST.request (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:1272:22)
at async InteractionWebhook.editMessage (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/discord.js/14.16.3/src/structures/Webhook.js:341:15)
at async ButtonInteraction.editReply (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/discord.js/14.16.3/src/structures/interfaces/InteractionResponses.js:162:17)
at async file:///C:/Users/Jurn Wubben/Documents/DCBot/src/commands/utility/coc.ts:570:5
error: Uncaught (in promise) DiscordAPIError[50027]: Invalid Webhook Token
at handleErrors (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:727:13)
at eventLoopTick (ext:core/01_core.js:175:7)
at async SequentialHandler.runRequest (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:1128:23)
at async SequentialHandler.queueRequest (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:959:14)
at async _REST.request (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/rest/2.4.0/dist/index.js:1272:22)
at async InteractionWebhook.editMessage (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/discord.js/14.16.3/src/structures/Webhook.js:341:15)
at async ButtonInteraction.editReply (file:///C:/Users/Jurn Wubben/AppData/Local/deno/npm/registry.npmjs.org/discord.js/14.16.3/src/structures/interfaces/InteractionResponses.js:162:17)
at async file:///C:/Users/Jurn Wubben/Documents/DCBot/src/commands/utility/coc.ts:570:5
and it crashes in this part of the code
const message = await interaction.reply({...clashMessage({
handle: clash,
langs,
modes,
players: [{ nickname: "loading..." }],
started: false,
}, interaction.user.id)});

// message.startThread({
// name: "Clash of Code",
// reason: "Discuss your coc here."
// })

await clashEventManager(clash, async (data) => {
await message.edit(clashMessage(data, interaction.user.id)); // CRASHES HERE
});
const message = await interaction.reply({...clashMessage({
handle: clash,
langs,
modes,
players: [{ nickname: "loading..." }],
started: false,
}, interaction.user.id)});

// message.startThread({
// name: "Clash of Code",
// reason: "Discuss your coc here."
// })

await clashEventManager(clash, async (data) => {
await message.edit(clashMessage(data, interaction.user.id)); // CRASHES HERE
});
the clahsEventManager is a function that runs the callback when there's a message received via socket.io I'll also upload my full code later.
35 replies
DIAdiscord.js - Imagine an app
Created by jsw on 12/22/2024 in #djs-questions
Send message to specific channel
Hi i'm trying to get a list of textchannels to log to. But when i use client.channels.fetch i keep getting 'null'? here's my code.
const channels: TextChannel[] = []
for (const i of config.SEXY_LOG_CHANNELS.split(",")) {
let channel: Channel | null | undefined;
try {
channel = client.channels.fetch(i);
} catch (e) {
if ((e as DiscordAPIError).code === 50001) console.error("SexyUP: Bot doesn't have access to this channel.", i)
continue
}
if (!channel || channel === null) {
console.error("SexyUP: Channel wasn't found.", i, i === null)

continue
}
if (!(channel instanceof TextChannel)) {
console.error("SexyUP: Message isn't a text channel", i)
continue
}
if (!client.user) {
console.error("SexyUP: Something went terribly wrong, the bot user doesn't exist? Very weird.")
continue
}

const permissions = channel.permissionsFor(client.user);
if (!permissions || !permissions.has("SendMessages")) {
console.error("SexyUP: No permissions to send messages in this channel. ", i, permissions)
continue
}

channels.push(channel)
}
const channels: TextChannel[] = []
for (const i of config.SEXY_LOG_CHANNELS.split(",")) {
let channel: Channel | null | undefined;
try {
channel = client.channels.fetch(i);
} catch (e) {
if ((e as DiscordAPIError).code === 50001) console.error("SexyUP: Bot doesn't have access to this channel.", i)
continue
}
if (!channel || channel === null) {
console.error("SexyUP: Channel wasn't found.", i, i === null)

continue
}
if (!(channel instanceof TextChannel)) {
console.error("SexyUP: Message isn't a text channel", i)
continue
}
if (!client.user) {
console.error("SexyUP: Something went terribly wrong, the bot user doesn't exist? Very weird.")
continue
}

const permissions = channel.permissionsFor(client.user);
if (!permissions || !permissions.has("SendMessages")) {
console.error("SexyUP: No permissions to send messages in this channel. ", i, permissions)
continue
}

channels.push(channel)
}
the config.SEXY_LOG_CHANNELS is an env var with the channels id seperated by commas.
38 replies
DIAdiscord.js - Imagine an app
Created by jsw on 12/14/2024 in #djs-questions
How do i delete a followup to a deferreply using a button?
I currently have await interaction.deleteReply() in the button callback but it gives the error error: Uncaught (in promise) DiscordAPIError[10015]: Unknown Webhook.
10 replies
DIAdiscord.js - Imagine an app
Created by jsw on 12/10/2024 in #djs-questions
check if bot is user installed (or check if dm permission without sending a message)
Hi is there a way to check if the bot is user-installed? I'd like to make a reminders userbot command that sends you a dm when the reminder's due. The only solution i've seen so far is to send a dm to someone but i'd prefer not double dms (one when running the command and one when the reminder's finished.)
6 replies