connor
connor
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
well the issue happens when displaying the modal, because its still in the original slash command context, so it says the interaction has already been sent or deffered
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
No description
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
one last thing, can i get the modal input the same as the button or will this require resetting up the whole thing
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
basically cant have the action decided prior to profile lookup
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
test game im implementing has like 1m monthly users but i want to do on much bigger projects w a lot of moderators and a lot of different actions
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
outside of discord
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
reason i don’t want ban slash commands, i need to review the profile prior to ban, and it won’t just be ban but other actions, based on their ingame performance
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
i’ll look into this rn
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
wait modals is perfect i thought they were drop downs
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
it’s mainly for cheaters, so game related info will be displayed with the ban option
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
yeah one slash command is easy enough, button also easy to click as well as just tying in anything, the input is what i don’t really like on mobile, but also want to verify it’s the right person before banning
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
if it’s the drop down i do like that, but i want moderators to be able to attach links to the ban messages
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
what would a modal look like in this context? also want to avoid it being a ban command bc it’s mainly so i can manage my games on mobile
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
async execute(interaction) {
try {
const message = interaction.options.getString("input");

const results = await cloud.getUsersData(message);
const data = await sendUser(interaction, message, results);
const response = await interaction.reply({ embeds: [data.embed], components: [data.row] });
const collectorFilter = i => i.user.id === interaction.user.id;
try {
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 60_000 });
console.log("confirmation=", confirmation.customId)
if (confirmation.customId == 'ban') {

await interaction.followUp({ content: 'Please enter your reason:', ephemeral: true });

const filter = m => m.author.id === interaction.user.id; // Collect messages only from the user who interacted
const collector = interaction.channel.createMessageCollector({ filter, max: 1, time: 60000 }); // Adjust time as needed
collector.on('collect', m => {
console.log(`Collected message: ${m.content}`);
// Process the response
// For example, implementing your ban logic here
});

cloud.editData(message, "Bans", 1)
console.log(interaction, "person")
const channel = interaction.client.channels.cache.get(gameInfo.test.log_channel);
const logmsg = `${interaction.user.username} banned user ${message}`
channel.send(logmsg)
await confirmation.update({ content: `${message} has been banned for reason`, components: [] });
} else if (confirmation.customId === 'cancel') {
await confirmation.update({ content: 'Action cancelled', components: [] });
}
} catch (e) {
console.error(e)
await interaction.editReply({ content: 'Confirmation not received within 1 minute, cancelling', components: [] });
}

} catch (error) {
console.error(error);
await interaction.reply({ content: 'Failed to find user', ephemeral: true });
}
},
},
async execute(interaction) {
try {
const message = interaction.options.getString("input");

const results = await cloud.getUsersData(message);
const data = await sendUser(interaction, message, results);
const response = await interaction.reply({ embeds: [data.embed], components: [data.row] });
const collectorFilter = i => i.user.id === interaction.user.id;
try {
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 60_000 });
console.log("confirmation=", confirmation.customId)
if (confirmation.customId == 'ban') {

await interaction.followUp({ content: 'Please enter your reason:', ephemeral: true });

const filter = m => m.author.id === interaction.user.id; // Collect messages only from the user who interacted
const collector = interaction.channel.createMessageCollector({ filter, max: 1, time: 60000 }); // Adjust time as needed
collector.on('collect', m => {
console.log(`Collected message: ${m.content}`);
// Process the response
// For example, implementing your ban logic here
});

cloud.editData(message, "Bans", 1)
console.log(interaction, "person")
const channel = interaction.client.channels.cache.get(gameInfo.test.log_channel);
const logmsg = `${interaction.user.username} banned user ${message}`
channel.send(logmsg)
await confirmation.update({ content: `${message} has been banned for reason`, components: [] });
} else if (confirmation.customId === 'cancel') {
await confirmation.update({ content: 'Action cancelled', components: [] });
}
} catch (e) {
console.error(e)
await interaction.editReply({ content: 'Confirmation not received within 1 minute, cancelling', components: [] });
}

} catch (error) {
console.error(error);
await interaction.reply({ content: 'Failed to find user', ephemeral: true });
}
},
},
most of the structure is from the tutorial page
client.on(Events.InteractionCreate, async interaction => {
if (interaction.isButton()) {
//console.log(interaction)
//commands.buttons[interaction.customId](interaction)
return
}
if (!interaction.isChatInputCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
client.on(Events.InteractionCreate, async interaction => {
if (interaction.isButton()) {
//console.log(interaction)
//commands.buttons[interaction.customId](interaction)
return
}
if (!interaction.isChatInputCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
20 replies
DIAdiscord.js - Imagine an app
Created by connor on 3/27/2024 in #djs-questions
Follow up response
v18.15.0
v18.15.0
20 replies