TheRealJohan™
TheRealJohan™
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
it was an issue on discord's side but it's fixed now
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
I've tried debugging some more and fount that: - sending it as a normal message works just fine - replying to an interaction works just fine - following up on an interaction does not work and causes an internal server error - editing an interaction does not work and causes an internal server error
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
2024-03-13 12:00:24 - DEBUG - [EvalCommand] Running evaluated script:
2024-03-13 12:00:24 - DEBUG - interaction.followUp({
2024-03-13 12:00:24 - DEBUG - content: "test",
2024-03-13 12:00:24 - DEBUG - components: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - type: 1, // Action row
2024-03-13 12:00:24 - DEBUG - components: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - custom_id: "test",
2024-03-13 12:00:24 - DEBUG - default_values: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - type: "channel",
2024-03-13 12:00:24 - DEBUG - id: "1215980641229733938", // This is a post inside a forum
2024-03-13 12:00:24 - DEBUG - },
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - placeholder: "Select a channel...",
2024-03-13 12:00:24 - DEBUG - channel_types: [
2024-03-13 12:00:24 - DEBUG - 0, // GUILD_TEXT
2024-03-13 12:00:24 - DEBUG - 10, // ANNOUNCEMENT_THREAD
2024-03-13 12:00:24 - DEBUG - 11, // PUBLIC_THREAD
2024-03-13 12:00:24 - DEBUG - 12, // PRIVATE_THREAD
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - min_values: 0,
2024-03-13 12:00:24 - DEBUG - max_values: 1,
2024-03-13 12:00:24 - DEBUG - type: 8, // Channel select
2024-03-13 12:00:24 - DEBUG - },
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - }
2024-03-13 12:00:24 - DEBUG - ]
2024-03-13 12:00:24 - DEBUG - })
2024-03-13 12:00:25 - ERROR - [EvalCommand] HTTPError: Internal Server Error
2024-03-13 12:00:25 - ERROR - at handleErrors (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:136:9)
2024-03-13 12:00:25 - ERROR - at SequentialHandler.runRequest (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:410:26)
2024-03-13 12:00:25 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-03-13 12:00:25 - ERROR - at SequentialHandler.queueRequest (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:168:11)
2024-03-13 12:00:25 - ERROR - at _REST.request (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/REST.ts:211:20)
2024-03-13 12:00:25 - ERROR - at async InteractionWebhook.send (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/[email protected]/node_modules/discord.js/src/structures/Webhook.js:222:15)
2024-03-13 12:00:25 - ERROR - at EvalCommand.eval (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/src/commands/developer/eval.ts:151:22)
2024-03-13 12:00:25 - ERROR - at <anonymous> (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/src/commands/developer/eval.ts:71:51)
2024-03-13 12:00:25 - ERROR - at <anonymous> (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/framework/src/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.ts:15:18)
2024-03-13 12:00:25 - ERROR - at Object.fromAsync (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/src/lib/Result.ts:51:19)
2024-03-13 12:00:24 - DEBUG - [EvalCommand] Running evaluated script:
2024-03-13 12:00:24 - DEBUG - interaction.followUp({
2024-03-13 12:00:24 - DEBUG - content: "test",
2024-03-13 12:00:24 - DEBUG - components: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - type: 1, // Action row
2024-03-13 12:00:24 - DEBUG - components: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - custom_id: "test",
2024-03-13 12:00:24 - DEBUG - default_values: [
2024-03-13 12:00:24 - DEBUG - {
2024-03-13 12:00:24 - DEBUG - type: "channel",
2024-03-13 12:00:24 - DEBUG - id: "1215980641229733938", // This is a post inside a forum
2024-03-13 12:00:24 - DEBUG - },
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - placeholder: "Select a channel...",
2024-03-13 12:00:24 - DEBUG - channel_types: [
2024-03-13 12:00:24 - DEBUG - 0, // GUILD_TEXT
2024-03-13 12:00:24 - DEBUG - 10, // ANNOUNCEMENT_THREAD
2024-03-13 12:00:24 - DEBUG - 11, // PUBLIC_THREAD
2024-03-13 12:00:24 - DEBUG - 12, // PRIVATE_THREAD
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - min_values: 0,
2024-03-13 12:00:24 - DEBUG - max_values: 1,
2024-03-13 12:00:24 - DEBUG - type: 8, // Channel select
2024-03-13 12:00:24 - DEBUG - },
2024-03-13 12:00:24 - DEBUG - ],
2024-03-13 12:00:24 - DEBUG - }
2024-03-13 12:00:24 - DEBUG - ]
2024-03-13 12:00:24 - DEBUG - })
2024-03-13 12:00:25 - ERROR - [EvalCommand] HTTPError: Internal Server Error
2024-03-13 12:00:25 - ERROR - at handleErrors (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/Shared.ts:136:9)
2024-03-13 12:00:25 - ERROR - at SequentialHandler.runRequest (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:410:26)
2024-03-13 12:00:25 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-03-13 12:00:25 - ERROR - at SequentialHandler.queueRequest (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/handlers/SequentialHandler.ts:168:11)
2024-03-13 12:00:25 - ERROR - at _REST.request (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@discordjs/rest/src/lib/REST.ts:211:20)
2024-03-13 12:00:25 - ERROR - at async InteractionWebhook.send (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/[email protected]/node_modules/discord.js/src/structures/Webhook.js:222:15)
2024-03-13 12:00:25 - ERROR - at EvalCommand.eval (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/src/commands/developer/eval.ts:151:22)
2024-03-13 12:00:25 - ERROR - at <anonymous> (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/src/commands/developer/eval.ts:71:51)
2024-03-13 12:00:25 - ERROR - at <anonymous> (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/framework/src/listeners/application-commands/chat-input/CoreChatInputCommandAccepted.ts:15:18)
2024-03-13 12:00:25 - ERROR - at Object.fromAsync (/Users/gus.libens/Desktop/Development/GitLab-LHS/private/discord/Dodoco/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/result/src/lib/Result.ts:51:19)
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
Yes no worries, in the development environment they just get sent in the message for ease of use 😄 The actual code is a lot more complex than this but it basically does this
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
No description
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by TheRealJohan™ on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
the code I ran through the evaluate command is simply this for debugging purposes:
interaction.followUp({
content: "test",
components: [
{
type: 1, // Action row
components: [
{
custom_id: "test",
default_values: [
{
type: "channel",
id: "1215980641229733938", // This is a post inside a forum
},
],
placeholder: "Select a channel...",
channel_types: [
0, // GUILD_TEXT
10, // ANNOUNCEMENT_THREAD
11, // PUBLIC_THREAD
12, // PRIVATE_THREAD
],
min_values: 0,
max_values: 1,
type: 8, // Channel select
},
],
}
]
})
interaction.followUp({
content: "test",
components: [
{
type: 1, // Action row
components: [
{
custom_id: "test",
default_values: [
{
type: "channel",
id: "1215980641229733938", // This is a post inside a forum
},
],
placeholder: "Select a channel...",
channel_types: [
0, // GUILD_TEXT
10, // ANNOUNCEMENT_THREAD
11, // PUBLIC_THREAD
12, // PRIVATE_THREAD
],
min_values: 0,
max_values: 1,
type: 8, // Channel select
},
],
}
]
})
10 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 8/21/2023 in #sapphire-support
Error: Module did not self-register
yeah, it's just when I have the source code compiled + run tests with vitest that it gives me that error 🤔 running with node works perfectly fine, thanks anyway tho
8 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 8/21/2023 in #sapphire-support
Error: Module did not self-register
yep, it's a strange issue, it works just fine if I delete the dist directory (currently using this as workaround) and I'm on LTS v18.17.1
8 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 8/21/2023 in #sapphire-support
Error: Module did not self-register
not sure if it's relevant but I'm using vitest and I'm on macOS (apple silicon) I already tried reinstalling node_modules, still the same error
8 replies
SIASapphire - Imagine a framework
Created by -Carlos🎃 on 8/18/2023 in #sapphire-support
Preconditions
you've already explained how you'd do it so I don't really get what you're stuck on? 😅 you'd just iterate over the command's preconditions to check if any of them fail and if so, delete the message based on that
7 replies
DIAdiscord.js - Imagine a boo! 👻
Created by xjanex on 7/30/2023 in #djs-questions
how to set my bot status to "watching"
you should learn javascript before building a discord bot
To create a bot with discord.js, you should have a fairly decent grasp of JavaScript itself. While you can make a bot with very little JavaScript and programming knowledge, trying to do so without understanding the language first will only hinder you. You may get stuck on many uncomplicated issues, struggle with solutions to incredibly easy problems, and all-in-all end up frustrated. Sounds pretty annoying.
- https://discordjs.guide/#before-you-begin
22 replies
DIAdiscord.js - Imagine a boo! 👻
Created by xjanex on 7/30/2023 in #djs-questions
how to set my bot status to "watching"
or it's assigned undefined
22 replies
DIAdiscord.js - Imagine a boo! 👻
Created by xjanex on 7/30/2023 in #djs-questions
how to set my bot status to "watching"
the error means what it says, the variable Discord doesn't exist in your file
22 replies
DIAdiscord.js - Imagine a boo! 👻
Created by xjanex on 7/30/2023 in #djs-questions
how to set my bot status to "watching"
so import discord
22 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 6/26/2023 in #sapphire-support
How can I bypass required user permissions?
in case anyone is wondering how I implemented it in the future: CustomPreconditionContainerSingle.ts
export class CustomPreconditionContainerSingle extends PreconditionContainerSingle {
/** Same as {@link CooldownOptions.filteredUsers} but for preconditions. */
private readonly filterUsers: Snowflake[] = [/* TODO: add user IDs here */]

public override messageRun(message: Message<boolean>, command: MessageCommand, context?: PreconditionContext | undefined): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(message, precondition)) return precondition.ok()

return super.messageRun(message, command, context)
}

// Check if it should get bypassed before running the native method

public override chatInputRun(
interaction: ChatInputCommandInteraction<CacheType>,
command: ChatInputCommand,
context?: PreconditionContext | undefined
): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(interaction, precondition)) return precondition.ok()

return super.chatInputRun(interaction, command, context)
}

public override contextMenuRun(
interaction: ContextMenuCommandInteraction<CacheType>,
command: ContextMenuCommand,
context?: PreconditionContext | undefined
): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(interaction, precondition)) return precondition.ok()

return super.contextMenuRun(interaction, command, context)
}

/** Returns whether the precondition should get bypassed. */
private checkBypass(messageOrInteraction: MessageOrInteraction, precondition: Precondition<PreconditionOptions>) {
const isMessage = messageOrInteraction instanceof Message
const author = isMessage ? messageOrInteraction.author : messageOrInteraction.user

// Bypass required user permissions
return precondition.name === 'UserPermissions' && this.filterUsers.includes(author.id)
}
}
export class CustomPreconditionContainerSingle extends PreconditionContainerSingle {
/** Same as {@link CooldownOptions.filteredUsers} but for preconditions. */
private readonly filterUsers: Snowflake[] = [/* TODO: add user IDs here */]

public override messageRun(message: Message<boolean>, command: MessageCommand, context?: PreconditionContext | undefined): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(message, precondition)) return precondition.ok()

return super.messageRun(message, command, context)
}

// Check if it should get bypassed before running the native method

public override chatInputRun(
interaction: ChatInputCommandInteraction<CacheType>,
command: ChatInputCommand,
context?: PreconditionContext | undefined
): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(interaction, precondition)) return precondition.ok()

return super.chatInputRun(interaction, command, context)
}

public override contextMenuRun(
interaction: ContextMenuCommandInteraction<CacheType>,
command: ContextMenuCommand,
context?: PreconditionContext | undefined
): PreconditionResult {
const precondition = container.stores.get('preconditions').get(this.name)

if (precondition && this.checkBypass(interaction, precondition)) return precondition.ok()

return super.contextMenuRun(interaction, command, context)
}

/** Returns whether the precondition should get bypassed. */
private checkBypass(messageOrInteraction: MessageOrInteraction, precondition: Precondition<PreconditionOptions>) {
const isMessage = messageOrInteraction instanceof Message
const author = isMessage ? messageOrInteraction.author : messageOrInteraction.user

// Bypass required user permissions
return precondition.name === 'UserPermissions' && this.filterUsers.includes(author.id)
}
}
CustomCommand.ts
export abstract class CustomCommand extends Command {
// Implementation to bypass required user permissions
protected override parseConstructorPreConditionsRequiredUserPermissions(options: Command.Options) {
const permissions = new PermissionsBitField(options.requiredUserPermissions)
if (permissions.bitfield !== 0n) {
const precondition = new CustomPreconditionContainerSingle({
name: 'UserPermissions',
context: { permissions }
})
this.preconditions.add(precondition)
}
}
}
export abstract class CustomCommand extends Command {
// Implementation to bypass required user permissions
protected override parseConstructorPreConditionsRequiredUserPermissions(options: Command.Options) {
const permissions = new PermissionsBitField(options.requiredUserPermissions)
if (permissions.bitfield !== 0n) {
const precondition = new CustomPreconditionContainerSingle({
name: 'UserPermissions',
context: { permissions }
})
this.preconditions.add(precondition)
}
}
}
9 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 6/26/2023 in #sapphire-support
How can I bypass required user permissions?
np, I'll extend the class and do it like that, thanks
9 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 6/26/2023 in #sapphire-support
How can I bypass required user permissions?
that's for cooldowns 😄 I already have that set up actually
9 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 6/24/2023 in #sapphire-support
I'm not receiving any Context Menu Command interactions
hm very weird, I tried to reproduce the issue in a new repository and now it's working for some reason I'll mess around some more and get back to you
6 replies
SIASapphire - Imagine a framework
Created by TheRealJohan™ on 6/24/2023 in #sapphire-support
I'm not receiving any Context Menu Command interactions
it doesn't, the only things I touched in the dashboard were the intents slash commands work perfectly fine tho edit: I added an interaction listener for debugging purposes and it looks like that's picking it up 😕 so that means it's not getting passed properly to contextMenuRun
6 replies