Events 如果成员说出特定单词discord py rewrite,则自动将其静音
我想要的是,如果用户在发送的消息中使用省略号,则暂时使其静音Events 如果成员说出特定单词discord py rewrite,则自动将其静音,events,discord,discord.py-rewrite,mute,discogs-api,Events,Discord,Discord.py Rewrite,Mute,Discogs Api,我想要的是,如果用户在发送的消息中使用省略号,则暂时使其静音ctx.send不工作,bot不向频道发送消息。它说,self.client.add\u角色不存在 Muted是我创建的一个没有任何发送消息权限的角色 知道为什么吗?我们将非常感谢您的帮助。我正在使用 AttributeError:'Message'对象没有属性'send'这是我得到的错误 [编辑] @commands.Cog.listener() async def on_message(self, ctx):
ctx.send
不工作,bot不向频道发送消息。它说,self.client.add\u角色
不存在
Muted
是我创建的一个没有任何发送消息权限的角色
知道为什么吗?我们将非常感谢您的帮助。我正在使用
AttributeError:'Message'对象没有属性'send'
这是我得到的错误
[编辑]
@commands.Cog.listener()
async def on_message(self, ctx):
if ctx.author.id == self.client.user.id:
return
if re.search("\.\.\.", ctx.content):
await ctx.send("you're... gonna get... muted... if you.. talk... like.. this...")
user = ctx.message.author
# print(str(user))
# print(str(message.content))
muted_role = discord.utils.get(ctx.author.guild.roles, name="Muted")
await self.client.add_roles(ctx.author, muted_role)
我查看了文档并完成了这项工作,非常感谢您的支持:)有很多错误,请查看 我已经给你改好了-
@commands.Cog.listener()
# @commands.command()
async def on_message(self, message):
if message.author.id == self.client.user.id:
return
if re.search("\.\.\.", message.content):
await message.channel.send("you're... gonna get... muted... if you.. talk... like.. this...")
user = message.author
muted_role = discord.utils.get(message.guild.roles, name="Muted")
await user.add_roles(muted_role, reason="you know what you did", atomic=True)
如果仍然有错误,请告诉我
上次编辑-
我在齿轮外为自己尝试了这个命令,效果非常好:)
有很多错误,请看一下 我已经给你改好了-
@commands.Cog.listener()
# @commands.command()
async def on_message(self, message):
if message.author.id == self.client.user.id:
return
if re.search("\.\.\.", message.content):
await message.channel.send("you're... gonna get... muted... if you.. talk... like.. this...")
user = message.author
muted_role = discord.utils.get(message.guild.roles, name="Muted")
await user.add_roles(muted_role, reason="you know what you did", atomic=True)
如果仍然有错误,请告诉我
上次编辑-
我在齿轮外为自己尝试了这个命令,效果非常好:)
尝试使用
wait self.user.add_角色(静音_角色)
AttributeError:“Status”对象没有属性“user”
这种情况尝试删除self
可能?尝试使用wait self.user.add_角色(静音_角色)
AttributeError:“Status”对象没有属性“user”
此事件尝试删除self
可能?将最后一行更改为等待self.user.添加角色(静音角色)
现在工作正常吗?是的,工作正常,谢谢将最后一行更改为等待self.user.添加角色(静音角色)
现在可以用了吗?可以,谢谢
@commands.Cog.listener()
async def on_message(self, message):
if message.author.id == self.client.user.id:
return
else:
await message.channel.send("you're... gonna get... muted... if you.. talk... like.. this...")
user = message.author
print(str(user))
print(str(message.content))
muted_role = discord.utils.get(message.guild.roles, name="Muted")
await self.user.add_roles(muted_role)
@client.event
async def on_message(message):
if message.author.id == client.user.id:
return
elif "test" in message.content:
await message.channel.send("you're... gonna get... muted... if you.. talk... like.. this...")
user = message.author
print(str(user))
print(str(message.content))
muted_role = discord.utils.get(message.guild.roles, name="Muted")
await user.add_roles(muted_role)
else:
return
await client.process_commands(message)