disclosuure
disclosuure
SIASapphire - Imagine a framework
Created by disclosuure on 11/18/2023 in #sapphire-support
Command.LoaderContext does not exist
I have been updating my code to the new versions recently released, and Command.Context has been deprecated, but Command.LoaderContext does not exist. Listener.LoaderContext does exist however. "@sapphire/framework": "^4.8.2",
12 replies
SIASapphire - Imagine a framework
Created by disclosuure on 11/2/2023 in #sapphire-support
Ephemeral PaginatedMessages are unusable
https://ss.clanware.org/CdquvjYO.png It always says that it's someone else's message. @sapphire/framework@npm:4.7.2 @sapphire/discord.js-utilities@npm:7.0.2
77 replies
SIASapphire - Imagine a framework
Created by disclosuure on 10/16/2023 in #sapphire-support
Commands not respecting cooldown preconditions
import { Command, RegisterSubCommand } from '@kaname-png/plugin-subcommands-advanced';
import { BucketScope } from '@sapphire/framework';

@RegisterSubCommand('legacy', (builder) =>
builder
.setName('raidrequest')
.setDescription("Mentions the raid request role.")
.addStringOption((option) =>
option
.setName("group")
.setDescription("The group requesting a raid.")
.setRequired(true)
),
)
export class UserCommand extends Command {
public constructor(context: Command.Context) {
super(context, {
cooldownDelay: 600_000, // 10 minutes
cooldownScope: BucketScope.Global,
});
}
public override async chatInputRun(interaction: Command.ChatInputInteraction<'cached'>) {
. . .
}
}
import { Command, RegisterSubCommand } from '@kaname-png/plugin-subcommands-advanced';
import { BucketScope } from '@sapphire/framework';

@RegisterSubCommand('legacy', (builder) =>
builder
.setName('raidrequest')
.setDescription("Mentions the raid request role.")
.addStringOption((option) =>
option
.setName("group")
.setDescription("The group requesting a raid.")
.setRequired(true)
),
)
export class UserCommand extends Command {
public constructor(context: Command.Context) {
super(context, {
cooldownDelay: 600_000, // 10 minutes
cooldownScope: BucketScope.Global,
});
}
public override async chatInputRun(interaction: Command.ChatInputInteraction<'cached'>) {
. . .
}
}
I'm trying to make a command only run once every 10 mins globally, but it seems to just run anyway. @sapphire/framework v4.7.0
50 replies
SIASapphire - Imagine a framework
Created by disclosuure on 10/7/2023 in #sapphire-support
Paginated message not editing reply (always seems to reply)
const display = new PaginatedMessage({
template: templateEmbed,
pageIndexPrefix: 'Case',
actions: [
{
customId: 'view_case',
style: ButtonStyle.Success,
type: ComponentType.Button,
emoji: ':mag_right:',
run(context) {
context.collector.stop();
CaseCommand.createCaseEmbed(cases[context.handler.index], interaction, collection);
}
},
...PaginatedMessage.defaultActions
]
});
const display = new PaginatedMessage({
template: templateEmbed,
pageIndexPrefix: 'Case',
actions: [
{
customId: 'view_case',
style: ButtonStyle.Success,
type: ComponentType.Button,
emoji: ':mag_right:',
run(context) {
context.collector.stop();
CaseCommand.createCaseEmbed(cases[context.handler.index], interaction, collection);
}
},
...PaginatedMessage.defaultActions
]
});
CaseCommand.createCaseEmbed creates another paginated message, and runs it.
C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ButtonInteraction.update (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:233:5)
at async safelyReplyToInteraction (file:///C:/Users/x/Documents/Clanware/clanware-bot/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:664:7)
at async _PaginatedMessage.handleCollect (file:///C:/Users/x/Documents/Clanware/clanware-bot/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:1667:11) {
...
C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:687
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ButtonInteraction.update (C:\Users\x\Documents\Clanware\clanware-bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:233:5)
at async safelyReplyToInteraction (file:///C:/Users/x/Documents/Clanware/clanware-bot/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:664:7)
at async _PaginatedMessage.handleCollect (file:///C:/Users/x/Documents/Clanware/clanware-bot/node_modules/@sapphire/discord.js-utilities/dist/index.mjs:1667:11) {
...
13 replies
SIASapphire - Imagine a framework
Created by disclosuure on 8/24/2023 in #sapphire-support
Button handler is not calling parse method
I have a button, it was working but it stopped for some reason on @sapphire/[email protected] Code
@ApplyOptions<InteractionHandler.Options>({
name: 'justice-submit',
interactionHandlerType: InteractionHandlerTypes.Button
})
export class ButtonHandler extends InteractionHandler {
public override parse(interaction: ButtonInteraction) {
console.log('button is executing');
...
}
...
}
@ApplyOptions<InteractionHandler.Options>({
name: 'justice-submit',
interactionHandlerType: InteractionHandlerTypes.Button
})
export class ButtonHandler extends InteractionHandler {
public override parse(interaction: ButtonInteraction) {
console.log('button is executing');
...
}
...
}
This never logs anything
7 replies
SIASapphire - Imagine a framework
Created by disclosuure on 7/17/2023 in #sapphire-support
Hide the page selector with paginated messages?
I'd love some help hiding this selector in my paginated message, I've looked through the docs but I'm unable to see a solution, thanks! https://ss.clanware.org/sg21mE.png
7 replies
SIASapphire - Imagine a framework
Created by disclosuure on 5/19/2023 in #sapphire-support
Bot no longer runs after conversion to Typescript
6 replies
SIASapphire - Imagine a framework
Created by disclosuure on 4/15/2023 in #sapphire-support
Using plugin-api to link accounts
I am creating a bot which requires the user to link their discord account to their roblox account, both have oauth2 endpoints. I have thought about two methods for authenticating but I am not sure how to implement using plugin-api. I will either generate a magic link that goes straight to roblox oauth, or have them log in with discord first and then roblox, but I am unsure how to redirect users once they go to a route. The only ways I can see the response being published is an error message, json, or plain text. Do I need to use a frontend framework such as express or can I do this entirely on the backend as I do not intent do have a frontend web page.
5 replies
SIASapphire - Imagine a framework
Created by disclosuure on 3/29/2023 in #sapphire-support
UserError listener not catching all errors
I am running an imported function in my command, and calling UserError in this file and when I do, it is not caught by the listener, and my bot crashes. Error Source: https://github.com/cosigyn/Clanware-V3/blob/master/src/mods.mjs#L229 Command: https://github.com/cosigyn/Clanware-V3/blob/master/src/commands/general/affiliate.mjs
3 replies
SIASapphire - Imagine a framework
Created by disclosuure on 3/25/2023 in #sapphire-support
UserErrors not being caught by listener - bot is crashing
messageCommandError.mjs
import { Events, Listener } from "@sapphire/framework";
import { send } from "@sapphire/plugin-editable-commands";
import { EmbedBuilder } from "discord.js";

export class UserEvent extends Listener {
constructor(context, options) {
super(context, {
...options,
once: false,
event: Events.MessageCommandError,
name: "messageCommandError",
});
}

async run({ context, message: content }, { message: msg }) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
if (Reflect.get(Object(context), "silent")) return;

const embed = new EmbedBuilder()
.setTitle("Command Failed")
.setDescription(content)
.setColor("Red")
.setTimestamp();

return send(msg, {
embeds: [embed],
allowedMentions: { users: [msg.author.id], roles: [] },
});
}
}
import { Events, Listener } from "@sapphire/framework";
import { send } from "@sapphire/plugin-editable-commands";
import { EmbedBuilder } from "discord.js";

export class UserEvent extends Listener {
constructor(context, options) {
super(context, {
...options,
once: false,
event: Events.MessageCommandError,
name: "messageCommandError",
});
}

async run({ context, message: content }, { message: msg }) {
// `context: { silent: true }` should make UserError silent:
// Use cases for this are for example permissions error when running the `eval` command.
if (Reflect.get(Object(context), "silent")) return;

const embed = new EmbedBuilder()
.setTitle("Command Failed")
.setDescription(content)
.setColor("Red")
.setTimestamp();

return send(msg, {
embeds: [embed],
allowedMentions: { users: [msg.author.id], roles: [] },
});
}
}
70 replies