X
X
xis22482020-07-31 23:35:37
Python
xis2248, 2020-07-31 23:35:37

How to make a bot unable to ping roles?

I need the bot to not be able to ping roles, only people.
Code:

@bot.command()
async def say(ctx, *arg):
    await ctx.message.delete()
    author = ctx.message.author
    msg = ctx.message.content
    if(msg.find("@everyone") == -1) and (msg.find("@here") == -1):
        await ctx.send(' '.join(arg))
    else: await ctx.send("Нельзя упоминать всех!")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-08-01
@xis2248

Everything you need is right in the Message class:

for m in ctx.message.mentions:
  print ("user mention %s" % m)
for m in ctx.message.role_mentions:
  print ("role mention %s" % m)
if ctx.message.mention_everyone:
  print ('everyone mention')

Accordingly, you need to do something like:
if ctx.message.role_mentions or ctx.message.mention_everyone:
  await ctx.send(author.mention+", не пингуй!")
else:
  await ctx.send(msg)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question