我有一个函数,它检查"your"是否更改为"you are",并且我在让机器人在检查后发送消息时遇到了问题。做这件事的正确方法是什么?(我希望这适用于所有频道。(
import discord
from discord.ext import commands
client = discord.Client()
bot = commands.Bot(command_prefix='$')
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
@client.event
async def on_message_edit(before,after):
if(before.content == "your" and after.content == "you're"):
# I want to send message here
client.run('Token') # I have my token here
将ctx添加到参数(before,after,ctx)
中,并且然后将await ctx.send("message")
放入您希望发送消息的位置。
参数before
和after
属于discord类型。消息discord.Message
有一个属性channel
,您可以使用该属性来使用函数send
。
@client.event
async def on_message_edit(before, after):
if before.content == 'your' and after.content == "you're":
await before.channel.send(send_whatever_you_want)