oxi
oxi
DIAdiscord.js - Imagine an app
Created by oxi on 7/9/2024 in #djs-questions
Welcome Message Sending multiple times
No description
12 replies
DIAdiscord.js - Imagine an app
Created by oxi on 1/18/2024 in #djs-questions
guildMemberUpdate, function not executing as expected
Node.js: v20.5.1 Discord.js: v14.13.0 https://hastebin.com/share/etonilifab.typescript This function executes completely fine on the second, third and fourth execution. However, on the first it is unable to get oldMember, as it is not cached. How would I be able to have it so that it allows for me to synchronise their roles correctly? I attempted to use partials yet this did not work as roles can be added yet not removed.
20 replies
DIAdiscord.js - Imagine an app
Created by oxi on 9/20/2023 in #djs-voice
Having an issue during installation
https://hastebin.com/share/vivaluruqo.ruby Tried to look for other people who may have asked the same question and tried to parse the error message myself yet cannot seem to figure out why it's not working or more specifically how to resolve the issue.
3 replies
DIAdiscord.js - Imagine an app
Created by oxi on 8/19/2023 in #djs-questions
Would it be possible to make this have a generic type?
export function generateActionRows<T>(buttons: ButtonBuilder[]): ActionRowBuilder<T> {
const actionRows: ActionRowBuilder<ButtonBuilder>[] = [];
let currentRow = new ActionRowBuilder<ButtonBuilder>();

for (const [i, button] of buttons.entries()) {
currentRow.addComponents(button);
if (currentRow.components.length === 5 || i === buttons.length - 1) {
actionRows.push(currentRow);
currentRow = new ActionRowBuilder();

}
}

return actionRows;
}
export function generateActionRows<T>(buttons: ButtonBuilder[]): ActionRowBuilder<T> {
const actionRows: ActionRowBuilder<ButtonBuilder>[] = [];
let currentRow = new ActionRowBuilder<ButtonBuilder>();

for (const [i, button] of buttons.entries()) {
currentRow.addComponents(button);
if (currentRow.components.length === 5 || i === buttons.length - 1) {
actionRows.push(currentRow);
currentRow = new ActionRowBuilder();

}
}

return actionRows;
}
I've not really used them too much and have been trying to follow along using the Typescript documentation, however getting a bit confused when it comes to making it work whilst adhering to the limits of AnyComponentBuilder, as I do get an error with this current code:
Type 'T' does not satisfy the constraint 'AnyComponentBuilder'.
Type 'T' is not assignable to type 'TextInputBuilder'.ts(2344)
buttons.ts(23, 36): This type parameter might need an `extends TextInputBuilder` constraint.
buttons.ts(23, 36): This type parameter might need an `extends AnyComponentBuilder` constraint.
Type 'T' does not satisfy the constraint 'AnyComponentBuilder'.
Type 'T' is not assignable to type 'TextInputBuilder'.ts(2344)
buttons.ts(23, 36): This type parameter might need an `extends TextInputBuilder` constraint.
buttons.ts(23, 36): This type parameter might need an `extends AnyComponentBuilder` constraint.
I attempted to fix this by extending AnyCompontentBuilder and then I get the following error upon compilation within all of my usages of the generateActionRows
src/buttons/embed_save.ts:102:17 - error TS2322: Type 'ActionRowBuilder<AnyComponentBuilder>[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.

102 components: [..._rowGroup1, ..._rowGroup2, ..._rowGroup3, ..._rowGroup4]
src/buttons/embed_save.ts:102:17 - error TS2322: Type 'ActionRowBuilder<AnyComponentBuilder>[]' is not assignable to type '(APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>)[]'.

102 components: [..._rowGroup1, ..._rowGroup2, ..._rowGroup3, ..._rowGroup4]
This is not much of an issue, just though tit would be nice if I could create one helper function for all ActionRowBuilder types rather than one per type.
9 replies
DIAdiscord.js - Imagine an app
Created by oxi on 8/3/2023 in #djs-questions
Autocomplete Command not sending update
Not too sure how to explain it exactly however, I have a command with multiple Autocomplete options, therefore I have added in a "key" option so they can select what specific key they are wanting. /config reset key:string value:AutocompleteString Here is an extract from my code(the portion responsible for AutocompleteInteractions for this specific command):
async ({ interaction, client }) => {
if (!interaction.guild) return;
const focusedValue = interaction.options.getFocused();

const group = interaction.options.getSubcommandGroup(true);
const command = interaction.options.getSubcommand(true);

const guild_config = await getGuildConfig(interaction.guild.id)

if (group == 'reset' && command == 'one') {
const key = interaction.options.getString('key', true);
let _options: string[] = [];

switch (key) {
case 'disabled-buttons': _options = guild_config.disabled_buttons; break;
case 'color': _options = guild_config.custom_colours.map(x => x.name); break;
case 'restricted-channels':
let _chans: string[] = [];
for (const channel of guild_config.restricted_channels) {
try {
const _chan = await client.channels.fetch(channel) as TextChannel;
_chans.push(_chan.name);
} catch (error) { }
}
_options = _chans;
break;
}
async ({ interaction, client }) => {
if (!interaction.guild) return;
const focusedValue = interaction.options.getFocused();

const group = interaction.options.getSubcommandGroup(true);
const command = interaction.options.getSubcommand(true);

const guild_config = await getGuildConfig(interaction.guild.id)

if (group == 'reset' && command == 'one') {
const key = interaction.options.getString('key', true);
let _options: string[] = [];

switch (key) {
case 'disabled-buttons': _options = guild_config.disabled_buttons; break;
case 'color': _options = guild_config.custom_colours.map(x => x.name); break;
case 'restricted-channels':
let _chans: string[] = [];
for (const channel of guild_config.restricted_channels) {
try {
const _chan = await client.channels.fetch(channel) as TextChannel;
_chans.push(_chan.name);
} catch (error) { }
}
_options = _chans;
break;
}
Here is a gif demonstrating what I am meaning: https://i.imgur.com/bu90n92.gif Versions: [email protected] [email protected]
4 replies
DIAdiscord.js - Imagine an app
Created by oxi on 5/26/2023 in #djs-questions
Interaction has already been acknowledged - yet I am not acknowledging it ?
I have had a look through my code and I will append it below, however, I do not see where the issue is appearing as it is stating that the command is already replied to. However, the only reply is the "Error Cannot Execute". Node Version: v16.10.0 Djs Version: v14.11.0
13 replies
DIAdiscord.js - Imagine an app
Created by oxi on 5/15/2023 in #djs-questions
awaitMessages not returning an output
const questionFilter = (m:Message) => {
return m.author.id == interaction.user.id;
}

channel.send( MessageReply.question(questions[question]) );

return await channel.awaitMessages({
filter: questionFilter,
max: 1,
time: 60000,
errors: ['time']
});
const questionFilter = (m:Message) => {
return m.author.id == interaction.user.id;
}

channel.send( MessageReply.question(questions[question]) );

return await channel.awaitMessages({
filter: questionFilter,
max: 1,
time: 60000,
errors: ['time']
});
6 replies
DIAdiscord.js - Imagine an app
Created by oxi on 5/14/2023 in #djs-questions
Typescript: ActionRowBuilder<> is not assignable.
I seem to be getting this error:
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.

Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.ts(2322)
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.

Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.ts(2322)
I'm using the code from the djs guide.
const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);

const row = new ActionRowBuilder()
.addComponents(select);

channel.send({
content: 'Select one!',
components: [row] // ts(2322)
})
const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);

const row = new ActionRowBuilder()
.addComponents(select);

channel.send({
content: 'Select one!',
components: [row] // ts(2322)
})
5 replies
DIAdiscord.js - Imagine an app
Created by oxi on 8/3/2022 in #djs-questions
TS - Typing issue with ModalSubmitInteraction.member
Argument of type 'GuildMember | APIInteractionGuildMember' is not assignable to parameter of type 'GuildMember'.
Argument of type 'GuildMember | APIInteractionGuildMember' is not assignable to parameter of type 'GuildMember'.
I am trying to get the GuildMember from a ModalSubmitInteraction - how would I resolve this error?
5 replies
DIAdiscord.js - Imagine an app
Created by oxi on 7/19/2022 in #djs-questions
TS - Setting colour on an embed doesn't work with variables?
3 replies
DIAdiscord.js - Imagine an app
Created by oxi on 6/25/2022 in #djs-questions
Odd TypeScript Error with D.JSv13.7
7 replies
DIAdiscord.js - Imagine an app
Created by oxi on 6/15/2022 in #djs-questions
Is there a Client.rest alternative in v13.8?
13 replies