0

I am trying to make a discord bot using Python and I want to make it so not everyone can mention @everyone or when they do the message will be deleted immediately, but then I have another code ($snipe) which doesn't work until I delete it, and after I do, it gives me the response! Any help would be appreciated!

@client.event
async def on_message(message):
    xall = "@everyone"
    
    role1 = discord.utils.get(message.guild.roles, name = "Owner")
    role2 = discord.utils.get(message.guild.roles, name="Mod")
    roles = role1 or role2

    if xall in message.content:
        if roles in message.author.roles:
            pass
        else:
            await message.delete(message)


#Fun
       
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@client.command()
async def snipe(ctx):
    await ctx.send("Aight, imma go snipe!")

@client.command()
async def slap(ctx, members: commands.Greedy[discord.Member], *, reason='no reason'):
    slapped = ", ".join(x.mention for x in members)
    await ctx.send('{} just got slapped for {}'.format(slapped, reason))
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
PanicKk
  • 13
  • 7

1 Answers1

0
import discord

from discord.ext import commands

client = discord.Client()

@client.event
async def on_message(msg):  
    owner = discord.utils.get(msg.guild.roles, name="Owner")
    mod = discord.utils.get(msg.guild.roles, name="Mod")

    roles = (owner, mod)

    if msg.mention_everyone:
        if not any(r in msg.author.roles for r in roles):
            await msg.delete()

client.run(TOKEN)

I have just ran this, and this works as expected. Removes the message if needed.

Joshua Nixon
  • 1,379
  • 2
  • 12
  • 25
  • I tried this but this one doesn't even delete the mention and the $snipe command still works only after I delete it :( – PanicKk Jan 14 '20 at 00:17
  • i think you need to add more information, such as are you using a selfbot, client, bot? My answer does exactly what you want using a ```Discord.Client bot```. – Joshua Nixon Jan 14 '20 at 00:22
  • I will try to fix it tomorrow cuz im actualy tired and its late, xd. Anyways thank you for your help :) – PanicKk Jan 14 '20 at 00:25