Discord.py - 上一个函数影响下一个函数



我正在尝试使用 Python 制作一个不和谐机器人,我想做到这一点,这样不是每个人都可以提及@everyone或者当他们这样做时,消息将立即被删除,但随后我有另一个代码 ($snipe( 在我删除它之前不起作用,在我这样做之后,它给了我响应!任何帮助将不胜感激!

@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))
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)

我刚刚运行了这个,这按预期工作。如果需要,删除邮件。

最新更新