Teixeira
Teixeira
Explore posts from servers
TtRPC
Created by Teixeira on 1/16/2025 in #❓-help
Route not found when using Fastify adapter
The client side url was missing the /trpc prefix set in the server.
4 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 1/13/2025 in #djs-questions
`ModalBuilder` validation error
I'm confused though I thought I'd only be able to import things that were direct dependencies of my project, not dependencies of dependencies
7 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 1/13/2025 in #djs-questions
`ModalBuilder` validation error
Ah I see. I don't have @discordjs/builders installed but I am using @sapphire/framework which does have it as a dependency
7 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 1/13/2025 in #djs-questions
`ModalBuilder` validation error
Damn.
7 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 1/13/2025 in #djs-questions
`ModalBuilder` validation error
import { ModalBuilder } from 'discord.js'; and import { ActionRowBuilder } from '@discordjs/builders';
7 replies
SIASapphire - Imagine a framework
Created by Teixeira on 12/30/2024 in #sapphire-support
`ApplicationCommandType` TypeError
I'm using npm workspaces and I had placed the overrides key in the workspace's package.json but it needed to be in my "root" package's package.json instead, that fixed it, thank you again for the help!
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 12/30/2024 in #sapphire-support
`ApplicationCommandType` TypeError
Yes I did :/ I'll check it out with them, thank you for the help! When/if I find the solution I'll post it here
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 12/30/2024 in #sapphire-support
`ApplicationCommandType` TypeError
Still getting the same error after setting overrides and running npm i (also tried deleting node_modules)
"dependencies": {
"@fastify/autoload": "^5.10.0",
"@fastify/bearer-auth": "^9.4.0",
"@fastify/type-provider-typebox": "^5.0.0",
"@sapphire/framework": "^5.2.1",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^7.0.0",
"@sapphire/string-store": "^1.2.0-next.3b1a353c",
"@sapphire/timestamp": "^1.0.3",
"@sinclair/typebox": "^0.32.34",
"discord.js": "^14.15.3",
"envalid": "^8.0.0",
"fastify": "^5.0.0",
"luxon": "^3.5.0",
"mongoose": "^8.6.4"
},
"overrides": {
"discord-api-types": "0.37.114"
},
"dependencies": {
"@fastify/autoload": "^5.10.0",
"@fastify/bearer-auth": "^9.4.0",
"@fastify/type-provider-typebox": "^5.0.0",
"@sapphire/framework": "^5.2.1",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^7.0.0",
"@sapphire/string-store": "^1.2.0-next.3b1a353c",
"@sapphire/timestamp": "^1.0.3",
"@sinclair/typebox": "^0.32.34",
"discord.js": "^14.15.3",
"envalid": "^8.0.0",
"fastify": "^5.0.0",
"luxon": "^3.5.0",
"mongoose": "^8.6.4"
},
"overrides": {
"discord-api-types": "0.37.114"
},
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/21/2024 in #sapphire-support
Precondition not triggering "chatInputCommandDenied"
Oh man. Of course... what a rookie mistake! Thank you, this fixed it!
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/21/2024 in #sapphire-support
Precondition not triggering "chatInputCommandDenied"
And here's the setting of the precondition on the command: CMServerDefaults.ts
export class CMServerDefaultsCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options, preconditions: ['ValidAutocompletedObjectIdArguments'] });
}

(...)
export class CMServerDefaultsCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options, preconditions: ['ValidAutocompletedObjectIdArguments'] });
}

(...)
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/21/2024 in #sapphire-support
Precondition not triggering "chatInputCommandDenied"
I know for a fact that the precondition is firing & returning an error in my test, as I've added a breakpoint to the return this.error (...) statement
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/21/2024 in #sapphire-support
Precondition not triggering "chatInputCommandDenied"
However, my chatInputCommandDenied listener isn't firing: ChatInputCommandDenied.ts
import { ChatInputCommandDeniedPayload, Events, Listener, type UserError } from '@sapphire/framework';
import Utils from '../lib/Utils.js';
import { CustomEmbedType } from '../ui/embeds/CustomEmbed.js';

export class ChatInputCommandDeniedListener extends Listener<typeof Events.ChatInputCommandDenied> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandDenied'
});
}

public async run(error: UserError, payload: ChatInputCommandDeniedPayload) {
try {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });

const reply = await payload.interaction.editReply({
embeds: [
(await this.container.ui.embeds.create(CustomEmbedType.Error)) //
.setDescription(error.message)
],
components: []
});

Utils.deleteAfterDelay(reply, payload.interaction.webhook);
} catch (reason) {
this.container.logger.error(reason);
}
}
}
import { ChatInputCommandDeniedPayload, Events, Listener, type UserError } from '@sapphire/framework';
import Utils from '../lib/Utils.js';
import { CustomEmbedType } from '../ui/embeds/CustomEmbed.js';

export class ChatInputCommandDeniedListener extends Listener<typeof Events.ChatInputCommandDenied> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: 'chatInputCommandDenied'
});
}

public async run(error: UserError, payload: ChatInputCommandDeniedPayload) {
try {
if (!payload.interaction.deferred) await payload.interaction.deferReply({ ephemeral: true });

const reply = await payload.interaction.editReply({
embeds: [
(await this.container.ui.embeds.create(CustomEmbedType.Error)) //
.setDescription(error.message)
],
components: []
});

Utils.deleteAfterDelay(reply, payload.interaction.webhook);
} catch (reason) {
this.container.logger.error(reason);
}
}
}
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/21/2024 in #sapphire-support
Precondition not triggering "chatInputCommandDenied"
ValidAutocompletedObjectIdArguments.ts
import { Precondition } from '@sapphire/framework';
import { ChatInputCommandInteraction, inlineCode } from 'discord.js';
import { Types } from 'mongoose';
import { RealmAutocompleteInteractionHandler } from '../interaction-handlers/RealmAutocompleteInteractionHandler.js';
import ZoneModeAutocompleteInteractionHandler from '../interaction-handlers/ZoneModeAutocompleteInteractionHandler.js';
import { RaidAutocompleteInteractionHandler } from '../interaction-handlers/RaidAutocompleteInteractionHandler.js';

export class ValidAutocompletedObjectIdArgumentsPrecondition extends Precondition {
private _autocompletedObjectIdOptionNames: string[] = [
RealmAutocompleteInteractionHandler.optionName,
ZoneModeAutocompleteInteractionHandler.optionName,
RaidAutocompleteInteractionHandler.optionName
];

public constructor(context: Precondition.LoaderContext, options: Precondition.Options) {
super(context, {
...options
});
}

public override async chatInputRun(interaction: ChatInputCommandInteraction) {
interaction.options.data.forEach((option) => {
if (
this._autocompletedObjectIdOptionNames.includes(option.name) &&
option.value &&
typeof option.value === 'string' &&
!Types.ObjectId.isValid(option.value)
) {
return this.error({
message: `Invalid parameter value for ${inlineCode(option.name)}. Please select one of the autocompleted options.`
});
}

return;
});

return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
ValidAutocompletedObjectIdArguments: never;
}
}
import { Precondition } from '@sapphire/framework';
import { ChatInputCommandInteraction, inlineCode } from 'discord.js';
import { Types } from 'mongoose';
import { RealmAutocompleteInteractionHandler } from '../interaction-handlers/RealmAutocompleteInteractionHandler.js';
import ZoneModeAutocompleteInteractionHandler from '../interaction-handlers/ZoneModeAutocompleteInteractionHandler.js';
import { RaidAutocompleteInteractionHandler } from '../interaction-handlers/RaidAutocompleteInteractionHandler.js';

export class ValidAutocompletedObjectIdArgumentsPrecondition extends Precondition {
private _autocompletedObjectIdOptionNames: string[] = [
RealmAutocompleteInteractionHandler.optionName,
ZoneModeAutocompleteInteractionHandler.optionName,
RaidAutocompleteInteractionHandler.optionName
];

public constructor(context: Precondition.LoaderContext, options: Precondition.Options) {
super(context, {
...options
});
}

public override async chatInputRun(interaction: ChatInputCommandInteraction) {
interaction.options.data.forEach((option) => {
if (
this._autocompletedObjectIdOptionNames.includes(option.name) &&
option.value &&
typeof option.value === 'string' &&
!Types.ObjectId.isValid(option.value)
) {
return this.error({
message: `Invalid parameter value for ${inlineCode(option.name)}. Please select one of the autocompleted options.`
});
}

return;
});

return this.ok();
}
}

declare module '@sapphire/framework' {
interface Preconditions {
ValidAutocompletedObjectIdArguments: never;
}
}
9 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/20/2024 in #discordjs-support
Is there a way to make autocomplete options only accept a listed option - not "custom" inputs?
Thank you both
7 replies
SIASapphire - Imagine a framework
Created by Teixeira on 11/20/2024 in #discordjs-support
Is there a way to make autocomplete options only accept a listed option - not "custom" inputs?
I see, I was hoping there was an alternative to validating the input (which is what I've been doing - in my case each option's value is an object id related to a mongoDB document, so now I just make it check if the value is a valid ObjectId string)
7 replies
SIASapphire - Imagine a framework
Created by Teixeira on 10/22/2024 in #sapphire-support
How can I delay the loading of pieces?
Think I should be able to do it with this but wanted to sanity check I'm not stupidly overthinking this and there's a much easier way to do it 😅
13 replies
SIASapphire - Imagine a framework
Created by Teixeira on 10/22/2024 in #sapphire-support
How can I delay the loading of pieces?
I want to load the emojis based on their names, and since I'm then using these custom emojis on some of my pieces, I want to make sure they're loaded before I start receiving events/commands
13 replies
SIASapphire - Imagine a framework
Created by Teixeira on 10/22/2024 in #sapphire-support
How can I delay the loading of pieces?
By the way since I have you here... This is related to something I'm trying to do for emojis after setting up your package @favware/discord-application-emojis-manager. I followed up on the message from your private server "Favware", not sure if you've seen it
13 replies
SIASapphire - Imagine a framework
Created by Teixeira on 10/22/2024 in #sapphire-support
How can I delay the loading of pieces?
Awesome this is exactly what I'm looking for
13 replies