如何使漫游器回复用户发送的内容?

时间:2020-09-29 20:29:26

标签: discord.py discord.py-rewrite

我正在制作一个赠品机器人,但我无法让机器人将用户所说的内容放入字段中。例如,机器人说:“您想赠与什么?”然后用户回复某些内容,然后机器人将其“内容”放入下一个回复中。

1 个答案:

答案 0 :(得分:0)

选择这个简单的机器人

import discord
from bot import search_result, get_recent_query


class MyClient(discord.Client):

    async def on_ready(self):
    """
    showing message on console when the server start
    :return:
    """
        print('Logged on as {0}!'.format(self.user))

    async def on_message(self, message):

        # event listener, where sending message is a event

        # we do not want the bot to reply to itself
        if message.author == client.user:
        return

        print('Message from {0.author}: {0.content}'.format(message))

    # checking the conditions, with which the user input starts
    # if user input is hi, return hey
        if message.content.startswith('hi'):
            msg = 'hey {0.author.mention} '.format(message)
            await message.channel.send(msg)

async def on_message(self, message)获得用户答复,这里的消息是用户答复,并以await message.channel.send(new_msg)的形式将处理后的数据发送给用户