Onlyin1
Onlyin1

Reputation: 1

Nextcord (discord.py) slash commands, bot doesn't ping even with admin perms

    @nextcord.slash_command(name = "chatrevive", description = "pings for chat revive", guild_ids=[ServerId])
@application_checks.has_role(982582539376025640)
@commands.cooldown(1, 7200, commands.BucketType.guild)
async def chatrevive(self, interaction: Interaction, msg: str):
    """Revive the chat!"""

    ping_role = interaction.guild.get_role(855720035426631690)
    embed = nextcord.Embed(title = '<a:tj_mochicat:941582560390160415> Chat Revive', color = 0xff0000)
    embed.set_author(name = interaction.guild.name, icon_url = interaction.guild.icon.url)
    embed.set_thumbnail(url=interaction.guild.icon.url)
    embed.description = f"<:tj_greendash:931018157689282581> **Message:** {msg}\n<:tj_greendash:931018157689282581> **Moderator:** {interaction.user.mention}"

    await interaction.send(content = ping_role.mention, embed = embed)
    await post_pinglog(self.bot, interaction.guild, "server-ping", interaction.user, ping_role, "N/A")

basically this is working, the only problem is that it mentions the role without pinging it. image that shows it

before anyone comments yes I did check the bot's permissions

Upvotes: 0

Views: 545

Answers (2)

DenverCoder1
DenverCoder1

Reputation: 2501

You need to set the allowed mentions for the message, for example, to allow mentioning roles:

await interaction.send(
    content=ping_role.mention,
    allowed_mentions=nextcord.AllowedMentions(roles=True),
)

Upvotes: 1

Onlyin1
Onlyin1

Reputation: 1

It seems that this is discord's fault, basically it's impossible to ping using interaction.send we'll have to use the following:

await interaction.send("Interaction completed.", ephemeral = True)
await interaction.channel.send(f"{ping_role.mention} yadi yadi yada")

Upvotes: 0

Related Questions