【发布时间】:2020-11-03 21:59:15
【问题描述】:
我正在设置一个简单的 Python Discord 机器人,但它似乎只响应一个事件/命令。它只在有人说“supreme sauce”时做出响应,它会发送“raw sauce”,但不响应“.ping”或“.clear”等其他任何内容。
我做错了什么吗?
我的代码:
import discord
from discord.ext import commands
import time
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print(f'{client.user} has successfully connected to Discord!')
@client.event
async def on_message(message):
if 'supreme sauce' in message.content:
await message.channel.send('raw sauce')
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
@client.command
async def clear(ctx, amount=10):
await ctx.channel.purge(limit=amount)
client.run('My Token')
【问题讨论】:
标签: python python-3.x discord discord.py