【发布时间】:2021-05-09 00:53:38
【问题描述】:
我正在尝试让我的不和谐机器人在某人开始打字时踢他们,并且想知道这是否可能。或者如果某个用户发送了一条消息。想知道这是否可能。到目前为止,这是我的代码:
#Import Discord
import discord
#Client And Pemrs
client = discord.Client()
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_typing(channel, user, when,):
if user.id == 574638576155754498:
general_channel = client.get_channel(784127484823339031)
await kick(reason="He said the word")
@client.event
async def on_ready():
#What The Bot Doing
@client.event
async def on_message(message):
if "Valorant" in message.content:
await message.author.kick(reason="He said the word")
if "valorant" in message.content:
await message.author.kick(reason="He said the word")
if "VALORANT" in message.content:
await message.author.kick(reason="He said the word")
#Run The Client
client.run('token')
提前感谢您的帮助。
【问题讨论】:
-
您必须将 on message 事件放在 on_ready 事件之外。您还需要在 on_typing 事件中使用 user.kick()。
标签: python discord.py