我对不和谐的bot的message.content有问题

时间:2019-04-15 21:58:17

标签: python

当我循环时,message.content永不刷新。

我尝试了很多事情,但是我真的不知道如何用Python编写代码。

import discord
import time
i = 0

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)
    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'start':
            while True:
                print(str(message.content))

client = MyClient()
client.run('TOKEN')

当我在Discord中重新键入消息时,我希望看到message.content刷新。有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

我还没有把机器人当成一类,但是在定义函数之前,我总是使用@运算符。我的机器人看起来像这样:

@bot.event # I think this is important
async def on_ready():
    await bot.change_presence(game=discord.Game(name="with your mom"))
    print(bot.user.name + ' is now up and running')

@bot.command(pass_context=True, description='stuff') # again I think this is important
async def process_command(ctx): # pass context of message into bot
    print(dir(ctx)) # show what methods are available (or just look up documentation)
    print(ctx)