【发布时间】:2020-07-25 03:41:49
【问题描述】:
我昨天切换到 cogs,所以我的代码看起来更干净。从那时起,所有命令都被破坏了。如果您发送 t!profile,它将发送两次消息。我发现问题与我创建的过滤器有关。
if getImmunityValue == 0:
for word in getWord:
if getMutedValue == 0:
message.content = message.content.lower()
if message.content.count(''.join(word)) > 0:
id = message.author.id
curs.execute('SELECT channelID FROM getchannel')
getChannelID = curs.fetchone()[0]
channel = self.client.get_channel(getChannelID)
curs.execute('SELECT strike FROM user WHERE userID = (%s)', (id,))
getstrike = curs.fetchone()[0]
curs.execute(f'UPDATE user SET strike = {getstrike + 1} WHERE userID = {id}')
db.commit()
await message.delete()
await message.channel.send(f'{message.author.mention} Bitte benutzte kein Schimpfwoerter. Falls du weiter machen solltest, wirst du gebannt oder gemutet!')
Embed = discord.Embed(
title=f'{getstrike}x strike(s) from {message.author}',
color=discord.Colour.red(),
timestamp=self.datetime.utcnow()
)
Embed.add_field(name='Blacklist Wort:', value=message.content, inline=False)
Embed.add_field(name='Channel-ID:', value=message.channel.id, inline=False)
Embed.add_field(name='Channel:', value=message.channel, inline=False)
await channel.send(embed=Embed)
await self.client.process_commands(message)
【问题讨论】:
-
您在
on_message事件中创建命令?你应该使用 discord.py 中的commands框架,它会简单得多:) -
不,我不知道。您看到的代码都在消息事件中
标签: python discord discord.py