Have this simple slash command which includes pinging/mentioning <@!${interaction.member.id}>
but it doesn't ping the mentioned user/role at all. I did enabled Mention @everyone, @here, and All Roles and tried to mention different users and roles still, it's not working.
This is the code:
run: async (client, interaction, args) => {
if(!interaction.member.permissions.has('MANAGE_CHANNELS')) {
return interaction.followUp({content: 'You don\'t have the required permission!'}).then(msg => {
setTimeout(() => {
msg.delete()
}, 3000)
})
}
const [subcommand] = args;
const embedevent = new MessageEmbed()
if(subcommand === 'create'){
const eventname = args[1]
const prize = args[2]
const sponsor = args[3]
embedevent.setDescription(`__**Event**__ <a:w_right_arrow:945334672987127869> ${eventname}\n__**Prize**__ <a:w_right_arrow:945334672987127869> ${prize}\n__**Donor**__ <a:w_right_arrow:945334672987127869> ${sponsor}`)
embedevent.setFooter(`${interaction.guild.name}`, `${interaction.guild.iconURL({ format: 'png', dynamic: true })}`)
embedevent.setTimestamp()
}
return interaction.followUp({content: `<@!${interaction.member.id}>`, embeds: [embedevent]})
}
}
The command is working just fine but the only problem is the pinging/mentioning.
CodePudding user response:
I'm not into interactions, but based on my experience doing bot, you should add the code first
const pingmember = interaction.mentions.members.first()
then you can do now
return interaction.followUp({content: `${pingmember}`, embeds: [embedevent]})
or
const pingmember = interaction.mentions.members.first()
if(pingmember) {
//your code here
}
CodePudding user response:
I kinda figured out about the problem. I simply added another interaction.followUp
await interaction.followUp({content: `Event started!`}).then(msg => {
setTimeout(() => {
msg.delete()
}, 5000)
})
and changed the return interaction.followUp
into return interaction.channel.send
. It didn't exactly answered my question but I'm contented with it.
Here's the final code:
run: async (client, interaction, args) => {
if(!interaction.member.permissions.has('MANAGE_CHANNELS')) {
return interaction.followUp({content: 'You don\'t have the required permission!'}).then(msg => {
setTimeout(() => {
msg.delete()
}, 3000)
})
}
const [subcommand] = args;
const embedevent = new MessageEmbed()
if(subcommand === 'create'){
const eventname = args[1]
const prize = args[2]
const sponsor = args[3]
embedevent.setDescription(`__**Event**__ <a:w_right_arrow:945334672987127869> ${eventname}\n__**Prize**__ <a:w_right_arrow:945334672987127869> ${prize}\n__**Donor**__ <a:w_right_arrow:945334672987127869> ${sponsor}`)
embedevent.setFooter(`${interaction.guild.name}`, `${interaction.guild.iconURL({ format: 'png', dynamic: true })}`)
embedevent.setTimestamp()
}
await interaction.followUp({content: `Event started!`}).then(msg => {
setTimeout(() => {
msg.delete()
}, 5000)
})
return interaction.channel.send({content: `<@!${interaction.member.id}>`, embeds: [embedevent]})
}
}