paulandrew
paulandrew
SIASapphire - Imagine a framework
Created by paulandrew on 2/5/2024 in #sapphire-support
Error when using @sapphire/type
dont use bun
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 2/5/2024 in #sapphire-support
Error when using @sapphire/type
use yarn instead of bun
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 2/5/2024 in #sapphire-support
Error when using @sapphire/type
works now
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 2/5/2024 in #sapphire-support
Error when using @sapphire/type
it still does not work
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/10/2023 in #discordjs-support
Problem with ChannelSelectMenuBuilder
so it update the embed but it still giving the error
5 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/10/2023 in #discordjs-support
Problem with ChannelSelectMenuBuilder
slr, i just woke up, anyways this is my full code below:
const {
InteractionHandler,
InteractionHandlerTypes,
container
} = require('@sapphire/framework');
const { EmbedBuilder } = require('discord.js');

module.exports = class SelectTicketCategory extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.SelectMenu
});
}

async run(interaction, result) {
try {
await interaction.update({
embeds: [result.data.embed]
});
} catch (err) {
console.log(err)
}
}

getSetupPanelMenu(id) {
return container.setupPanelMenu.find(item => item.setupSessionId === id);
}

async parse(interaction) {
if (interaction.customId !== 'select-ticket-category-dropdown') return this.none();

const messageId = interaction.message.id;
console.log(interaction.values)
const selectedCategory = interaction.values[0];
(container.setupPanelMenu.find(item => item.setupSessionId === messageId)).ticketCategory = selectedCategory;

const preSaveTicketCategory = this.getSetupPanelMenu(messageId).ticketCategory;

const colelctionEmbed = new EmbedBuilder(interaction.message.embeds[0].data)
.setFields(
{ name: '> > Selected Category <', value: preSaveTicketCategory === null ? 'Selecting...' : `<#${preSaveTicketCategory}>`, inline: false }
);

return this.some({ data: { embed: colelctionEmbed } });
}
}
const {
InteractionHandler,
InteractionHandlerTypes,
container
} = require('@sapphire/framework');
const { EmbedBuilder } = require('discord.js');

module.exports = class SelectTicketCategory extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.SelectMenu
});
}

async run(interaction, result) {
try {
await interaction.update({
embeds: [result.data.embed]
});
} catch (err) {
console.log(err)
}
}

getSetupPanelMenu(id) {
return container.setupPanelMenu.find(item => item.setupSessionId === id);
}

async parse(interaction) {
if (interaction.customId !== 'select-ticket-category-dropdown') return this.none();

const messageId = interaction.message.id;
console.log(interaction.values)
const selectedCategory = interaction.values[0];
(container.setupPanelMenu.find(item => item.setupSessionId === messageId)).ticketCategory = selectedCategory;

const preSaveTicketCategory = this.getSetupPanelMenu(messageId).ticketCategory;

const colelctionEmbed = new EmbedBuilder(interaction.message.embeds[0].data)
.setFields(
{ name: '> > Selected Category <', value: preSaveTicketCategory === null ? 'Selecting...' : `<#${preSaveTicketCategory}>`, inline: false }
);

return this.some({ data: { embed: colelctionEmbed } });
}
}
5 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
i used createMessageComponentCollector() instead of doing it all in the button interaction handler
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
fixed it, my shitty code is the problem
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
and anyways i can improve this code?
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
heres the code i mentioned that use the interaction.update():
const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework');
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

module.exports = class SetupCommand extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

async run(interaction, result) {
await interaction.update({ embeds: [result.embed], components: [result.row] });
}

async parse(interaction) {
const customId = interaction.customId;
if (customId.startsWith('createPanelBtn')) {
return this.some(this.getType('setupEmbed')) // Step 1: Create panel name
} else if (customId.startsWith('goBackBtn')) { // Go to previous step
return this.some(this.getType('goBack', 'intro'))
}

this.none()
}


getType(type, step = null) {
if (type === 'intro') {
const embed = new EmbedBuilder()
.setTitle('TItle about explaining the thing')
.setDescription('Some text here explaining things')
.setColor('Blue');

const createPanel = new ButtonBuilder()
.setCustomId('createPanelBtn')
.setLabel('Create A Panel')
.setStyle(ButtonStyle.Secondary);

return {
embed,
row: new ActionRowBuilder()
.addComponents(createPanel)
};
} else if (type === 'setupEmbed') {
const embed = new EmbedBuilder()
.setTitle('Step 1: Setting Up the embed')
.setDescription('Setting up the embed?');

const setupEmbedBtn = new ButtonBuilder()
.setCustomId('setupEmbedBtn')
.setLabel('Setup Panel Content')
.setStyle(ButtonStyle.Secondary);

const continuePanelBtn = new ButtonBuilder()
.setCustomId('continuePanelBtn')
.setLabel('Save & Continue')
.setStyle(ButtonStyle.Success);

const goBackBtn = new ButtonBuilder()
.setCustomId('goBackBtn')
.setLabel('Back')
.setStyle(ButtonStyle.Secondary);

return {
embed,
row: new ActionRowBuilder()
.addComponents(goBackBtn, setupEmbedBtn, continuePanelBtn)
};
} else if (type === 'goBack' && step !== null) {
let data;
switch (step) {
case 'intro':
data = this.getType('intro')
break;
case 'step1':
data = this.getType('setupEmbed')
break;
default:
return this.none();
}
return data
}
}
}
const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework');
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

module.exports = class SetupCommand extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
}

async run(interaction, result) {
await interaction.update({ embeds: [result.embed], components: [result.row] });
}

async parse(interaction) {
const customId = interaction.customId;
if (customId.startsWith('createPanelBtn')) {
return this.some(this.getType('setupEmbed')) // Step 1: Create panel name
} else if (customId.startsWith('goBackBtn')) { // Go to previous step
return this.some(this.getType('goBack', 'intro'))
}

this.none()
}


getType(type, step = null) {
if (type === 'intro') {
const embed = new EmbedBuilder()
.setTitle('TItle about explaining the thing')
.setDescription('Some text here explaining things')
.setColor('Blue');

const createPanel = new ButtonBuilder()
.setCustomId('createPanelBtn')
.setLabel('Create A Panel')
.setStyle(ButtonStyle.Secondary);

return {
embed,
row: new ActionRowBuilder()
.addComponents(createPanel)
};
} else if (type === 'setupEmbed') {
const embed = new EmbedBuilder()
.setTitle('Step 1: Setting Up the embed')
.setDescription('Setting up the embed?');

const setupEmbedBtn = new ButtonBuilder()
.setCustomId('setupEmbedBtn')
.setLabel('Setup Panel Content')
.setStyle(ButtonStyle.Secondary);

const continuePanelBtn = new ButtonBuilder()
.setCustomId('continuePanelBtn')
.setLabel('Save & Continue')
.setStyle(ButtonStyle.Success);

const goBackBtn = new ButtonBuilder()
.setCustomId('goBackBtn')
.setLabel('Back')
.setStyle(ButtonStyle.Secondary);

return {
embed,
row: new ActionRowBuilder()
.addComponents(goBackBtn, setupEmbedBtn, continuePanelBtn)
};
} else if (type === 'goBack' && step !== null) {
let data;
switch (step) {
case 'intro':
data = this.getType('intro')
break;
case 'step1':
data = this.getType('setupEmbed')
break;
default:
return this.none();
}
return data
}
}
}
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
So now my problem is how can i get the new interaction, which will i get after i use the interaction.update()?
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
aight so after like a 3 hours of debugging finnaly know what causing it: So even when i clicked the button that has the unique id of setupEmbedBtn it still wont work because the interaction in the above code is old, and so it returns the this.none(), i havent setup a error handler for that thats why i think it returns the error Why i say its old because in my other button interaction handler code, i use the interaction.update() method to edit the embed and components, but i think in the above code its still getting the interaction before i use the interaction.update()
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework');
const { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = class CreateEmbed extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
};

async run(interaction, result) {
await interaction.showModal(result);
}

async parse(interaction) {

if (interaction.customId !== 'setupEmbedBtn') {
console.log(interaction.customId)
return this.none();
}

try {
const modal = new ModalBuilder()
.setCustomId('setupEmbedMdl')
.setTitle('Setup Embed')

const embedGeneratorInput = new TextInputBuilder()
.setCustomId('embedGeneratorInput')
.setLabel('Pase the json code here or the url')
.setMaxLength(3000)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true);

const firstActionRow = new ActionRowBuilder()
.addComponents(embedGeneratorInput);

modal.addComponents(firstActionRow);
return this.some(modal)
} catch (err) {
console.log(err)
}

}
}
const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework');
const { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');

module.exports = class CreateEmbed extends InteractionHandler {
constructor(ctx, options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button
});
};

async run(interaction, result) {
await interaction.showModal(result);
}

async parse(interaction) {

if (interaction.customId !== 'setupEmbedBtn') {
console.log(interaction.customId)
return this.none();
}

try {
const modal = new ModalBuilder()
.setCustomId('setupEmbedMdl')
.setTitle('Setup Embed')

const embedGeneratorInput = new TextInputBuilder()
.setCustomId('embedGeneratorInput')
.setLabel('Pase the json code here or the url')
.setMaxLength(3000)
.setStyle(TextInputStyle.Paragraph)
.setRequired(true);

const firstActionRow = new ActionRowBuilder()
.addComponents(embedGeneratorInput);

modal.addComponents(firstActionRow);
return this.some(modal)
} catch (err) {
console.log(err)
}

}
}
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
still same error when i add it
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/3/2023 in #sapphire-support
Error when creating a modal
No description
14 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/1/2023 in #sapphire-support
Fetch reply from a command to button interaction
anyways thanks for the help
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/1/2023 in #sapphire-support
Fetch reply from a command to button interaction
reply*
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 12/1/2023 in #sapphire-support
Fetch reply from a command to button interaction
Eyy sorry for late repl
8 replies
SIASapphire - Imagine a framework
Created by paulandrew on 11/10/2023 in #sapphire-support
Slash command not working
nvm its problem with host, takes too long to update my files when i edit them
8 replies