Xu Xiaolan
Xu Xiaolan
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
did message.deferUpdate(); and it works out now, so thats great
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
okay, i figured out a way to make it run, i need to switch message.reply to message.channel.send, but that also just feels super awkward with the button since itll say "interaction failed", anyone know a fix?
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
please include a ping in responses, and thanks for any help ❤️
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
and im not sure why
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
isnt working
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
but the callback im using there
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
and this is confirmButtons
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
async function confirmButtons(userId, message, battleMessage, embeds, time, callback) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('yes')
.setLabel('Yes')
.setStyle(ButtonStyle.Success)
.setEmoji('✔️'),
new ButtonBuilder()
.setCustomId('no')
.setLabel('No')
.setStyle(ButtonStyle.Danger)
.setEmoji('✖️'),
);

const embed = embeds;
const response = await message.reply({
embeds: [embed],
components: [row],
ephemeral: true
});

const filter = (interaction) => {
return interaction.user.id === userId;
};
const collector = response.createMessageComponentCollector({ filter, time});

collector.on('collect', async interaction => {
if (interaction.customId === 'yes') {
const newBattleEmbed = new EmbedBuilder(battleMessage.embeds[0]).setColor('#808080');
await battleMessage.edit({
embeds: [newBattleEmbed],
components: [],
});
callback(["yes", interaction.user]);
response.delete();
collector.stop();
}
else if (interaction.customId === 'no') {
callback(["no", interaction.user]);
response.delete();
collector.stop();
}
});
collector.on('end', async () => {
});
}
async function confirmButtons(userId, message, battleMessage, embeds, time, callback) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('yes')
.setLabel('Yes')
.setStyle(ButtonStyle.Success)
.setEmoji('✔️'),
new ButtonBuilder()
.setCustomId('no')
.setLabel('No')
.setStyle(ButtonStyle.Danger)
.setEmoji('✖️'),
);

const embed = embeds;
const response = await message.reply({
embeds: [embed],
components: [row],
ephemeral: true
});

const filter = (interaction) => {
return interaction.user.id === userId;
};
const collector = response.createMessageComponentCollector({ filter, time});

collector.on('collect', async interaction => {
if (interaction.customId === 'yes') {
const newBattleEmbed = new EmbedBuilder(battleMessage.embeds[0]).setColor('#808080');
await battleMessage.edit({
embeds: [newBattleEmbed],
components: [],
});
callback(["yes", interaction.user]);
response.delete();
collector.stop();
}
else if (interaction.customId === 'no') {
callback(["no", interaction.user]);
response.delete();
collector.stop();
}
});
collector.on('end', async () => {
});
}
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
This is the code that leads to my function called confirmButtons
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 9/1/2023 in #djs-questions
Button callback not working
async function battleButtons(player1Id, player2Id, interaction, user1Cards, user2Cards, battleEmbed, time, battleSession, callback) {

const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('switch')
.setLabel('Switch')
.setStyle(ButtonStyle.Primary)
.setEmoji('🔀'),
new ButtonBuilder()
.setCustomId('fight')
.setLabel('Fight')
.setStyle(ButtonStyle.Primary)
.setEmoji('⚔️'),
new ButtonBuilder()
.setCustomId('forfeit')
.setLabel('Forfeit')
.setStyle(ButtonStyle.Danger)
.setEmoji('🏳️'),
);

const embed = battleEmbed;
const response = await interaction.followUp({
embeds: [embed],
components: [row],
});

const filter = (interaction) => {
return interaction.user.id === player1Id || interaction.user.id === player2Id;
};
const collector = response.createMessageComponentCollector({ filter, time});

collector.on('collect', async interaction => {
let userCards = [];
if (interaction.customId === 'forfeit') {
if (battleSession.state === "Player1Won" || battleSession.state === "Player2Won") {
const newBattleEmbed = new EmbedBuilder(response.embeds[0]).setColor('#808080'); // Edit the initial embed
await response.edit({ // Edit the initial message
embeds: [newBattleEmbed],
components: [], // Remove all components (buttons)
});
return;
}
const confirmEmbed = new EmbedBuilder()
.setColor(0x028A0F)
.setTitle("Would you like to end the battle?")
confirmButtons(interaction.user.id, interaction, response, confirmEmbed, 30 * 1000, callback); // Pass the 'response' as 'battleMessage' to 'confirmButtons'
}
async function battleButtons(player1Id, player2Id, interaction, user1Cards, user2Cards, battleEmbed, time, battleSession, callback) {

const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('switch')
.setLabel('Switch')
.setStyle(ButtonStyle.Primary)
.setEmoji('🔀'),
new ButtonBuilder()
.setCustomId('fight')
.setLabel('Fight')
.setStyle(ButtonStyle.Primary)
.setEmoji('⚔️'),
new ButtonBuilder()
.setCustomId('forfeit')
.setLabel('Forfeit')
.setStyle(ButtonStyle.Danger)
.setEmoji('🏳️'),
);

const embed = battleEmbed;
const response = await interaction.followUp({
embeds: [embed],
components: [row],
});

const filter = (interaction) => {
return interaction.user.id === player1Id || interaction.user.id === player2Id;
};
const collector = response.createMessageComponentCollector({ filter, time});

collector.on('collect', async interaction => {
let userCards = [];
if (interaction.customId === 'forfeit') {
if (battleSession.state === "Player1Won" || battleSession.state === "Player2Won") {
const newBattleEmbed = new EmbedBuilder(response.embeds[0]).setColor('#808080'); // Edit the initial embed
await response.edit({ // Edit the initial message
embeds: [newBattleEmbed],
components: [], // Remove all components (buttons)
});
return;
}
const confirmEmbed = new EmbedBuilder()
.setColor(0x028A0F)
.setTitle("Would you like to end the battle?")
confirmButtons(interaction.user.id, interaction, response, confirmEmbed, 30 * 1000, callback); // Pass the 'response' as 'battleMessage' to 'confirmButtons'
}
12 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/23/2023 in #djs-questions
quick question about module.export aliases for commands
❤️ will try
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/23/2023 in #djs-questions
quick question about module.export aliases for commands
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/21/2023 in #djs-questions
getting message.author esque information
ill try figuring out the rest, thats exactly what i needed tho thx
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/21/2023 in #djs-questions
getting message.author esque information
ah ic
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/21/2023 in #djs-questions
getting message.author esque information
client user would be the person who wrote the command?
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 8/21/2023 in #djs-questions
getting message.author esque information
i know my question is very weirdly worded, but my command is smthn like t.challenge against the bot, and i wanna use the bot's information for like pfp's etc but it wouldnt make sense to do t.challenge @botnamestuff and get the information like that
8 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 6/13/2023 in #djs-questions
disable select menu
welp thanks
9 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 6/13/2023 in #djs-questions
disable select menu
hmm alright, i could've sworen it was a thing, but i must've gotten it confused with that
9 replies
DIAdiscord.js - Imagine an app
Created by Xu Xiaolan on 6/13/2023 in #djs-questions
disable select menu
only view
9 replies