darby
darby
DIAdiscord.js - Imagine an app
Created by darby on 8/1/2023 in #djs-questions
CommandInteractionOptionResolver broke since updating to v.14.12.1
src/commands/test.command.ts:35:32 - error TS2339: Property 'getString' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'.

35 ? (interaction.options.getString('profile') as string)
~~~~~~~~~
src/commands/test.command.ts:36:32 - error TS2339: Property 'getUser' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'.

36 : (interaction.options.getUser('user')?.id as string);
src/commands/test.command.ts:35:32 - error TS2339: Property 'getString' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'.

35 ? (interaction.options.getString('profile') as string)
~~~~~~~~~
src/commands/test.command.ts:36:32 - error TS2339: Property 'getUser' does not exist on type 'Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused">'.

36 : (interaction.options.getUser('user')?.id as string);
4 replies
DIAdiscord.js - Imagine an app
Created by darby on 8/1/2023 in #djs-questions
CommandInteractionOptionResolver broke since updating to v.14.12.1
Code for resolving options (worked perfectly fine yesterday)
let commandOption: Steam.Profile | string =
commandGroup === 'profiles'
? (interaction.options.getString('profile') as string)
: (interaction.options.getUser('user')?.id as string);
let commandOption: Steam.Profile | string =
commandGroup === 'profiles'
? (interaction.options.getString('profile') as string)
: (interaction.options.getUser('user')?.id as string);
This worked fine yesterday.. however when I start the bot it crashes now before even being able to execute the command
4 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/25/2023 in #djs-questions
How to access interaction.options.getSubcommand()
thanks a lot !
8 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/25/2023 in #djs-questions
How to access interaction.options.getSubcommand()
export interface Command<T extends any[] = any[], R = void> {
data: SlashCommandSubcommandsOnlyBuilder & {
toJSON: () => any;
};
onExecution: (...args: T) => Promise<R> | R;
}
export interface Command<T extends any[] = any[], R = void> {
data: SlashCommandSubcommandsOnlyBuilder & {
toJSON: () => any;
};
onExecution: (...args: T) => Promise<R> | R;
}
8 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/25/2023 in #djs-questions
How to access interaction.options.getSubcommand()
Idk if this has anything to do with the type of the command
8 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/25/2023 in #djs-questions
How to access interaction.options.getSubcommand()
8 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/25/2023 in #djs-questions
How to access interaction.options.getSubcommand()
import {
SlashCommandBuilder,
CommandInteraction,
EmbedBuilder,
} from 'discord.js';
import {Discord} from '../../types/discord';

async function doHandleWhitelistCommandExecution(
interaction: CommandInteraction
): Promise<void> {
const options = interaction.options;
const action = interaction.commandName;
const profile = options.get('profile')?.value;

await interaction.reply(`Profile: ${profile} - Action: ${action}`);
}

const whitelistCommandHandler: Discord.Command = {
data: new SlashCommandBuilder()
.setName('whitelist')
.setDescription(
'Allows you to either add a user to the whitelist or to remove them'
)
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('Add a player to the whitelist')
.addStringOption(option =>
option
.setName('profile')
.setDescription('Represents a link to a steam profile')
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName('remove')
.setDescription('Remove a player from the whitelist')
.addStringOption(option =>
option
.setName('profile')
.setDescription('Represents a link to a steam profile')
.setRequired(true)
)
),
onExecution: doHandleWhitelistCommandExecution,
};

export default whitelistCommandHandler;
import {
SlashCommandBuilder,
CommandInteraction,
EmbedBuilder,
} from 'discord.js';
import {Discord} from '../../types/discord';

async function doHandleWhitelistCommandExecution(
interaction: CommandInteraction
): Promise<void> {
const options = interaction.options;
const action = interaction.commandName;
const profile = options.get('profile')?.value;

await interaction.reply(`Profile: ${profile} - Action: ${action}`);
}

const whitelistCommandHandler: Discord.Command = {
data: new SlashCommandBuilder()
.setName('whitelist')
.setDescription(
'Allows you to either add a user to the whitelist or to remove them'
)
.addSubcommand(subcommand =>
subcommand
.setName('add')
.setDescription('Add a player to the whitelist')
.addStringOption(option =>
option
.setName('profile')
.setDescription('Represents a link to a steam profile')
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName('remove')
.setDescription('Remove a player from the whitelist')
.addStringOption(option =>
option
.setName('profile')
.setDescription('Represents a link to a steam profile')
.setRequired(true)
)
),
onExecution: doHandleWhitelistCommandExecution,
};

export default whitelistCommandHandler;
8 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Well I guess I am better of with using the mainlib for now
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Ohhh okay 😄 I really thought it's the new way 😅
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
But I guess not haha
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
So I assumed this is new go to
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Well.. I went to the discordjs site and clicked on docs to see what is new since it's a bit since I wrote a bot.. so there I just saw that it said you need to npm i @discordjs/core
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Or atleast saying the /core package
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Uhmm okay.. well the whole WebSocket thing is kinda new to me.. guess I gotta need way more time 😅
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
I do need to change the onEmit because of the params with client
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Atleast this is what I have done now
async function doHandleReadyEvent(client: Client): Promise<void> {
client.api.users
.getCurrent()
.then(user => {
logger.info(`Bot successfully logged in! Username: ${user.username}`);
})
.catch(error => {
logger.error(`Error occured during login process! Error: ${error}`);
});
}

const readyEvent: Discord.Event<WebSocketShardEvents.Ready> = {
type: WebSocketShardEvents.Ready,
once: true,
onEmit: doHandleReadyEvent,
};
async function doHandleReadyEvent(client: Client): Promise<void> {
client.api.users
.getCurrent()
.then(user => {
logger.info(`Bot successfully logged in! Username: ${user.username}`);
})
.catch(error => {
logger.error(`Error occured during login process! Error: ${error}`);
});
}

const readyEvent: Discord.Event<WebSocketShardEvents.Ready> = {
type: WebSocketShardEvents.Ready,
once: true,
onEmit: doHandleReadyEvent,
};
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Well yep I guess I have to use WebSocketShardEvents.Ready then ?
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
Oh alright that's good to know
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
export interface Event {
type: keyof ManagerShardEventsMap;
once: boolean;
onEmit: (...args: any[]) => Promise<void>;
}
export interface Event {
type: keyof ManagerShardEventsMap;
once: boolean;
onEmit: (...args: any[]) => Promise<void>;
}
21 replies
DIAdiscord.js - Imagine an app
Created by darby on 7/24/2023 in #djs-questions
Help with @discordjs/core - interactionCreate argument passing
like this`?
21 replies