Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Discord.py 试图使Discord bot发送使用多个随机选择的单词的消息_Discord.py - Fatal编程技术网

Discord.py 试图使Discord bot发送使用多个随机选择的单词的消息

Discord.py 试图使Discord bot发送使用多个随机选择的单词的消息,discord.py,Discord.py,我想用Discord.py创建一个Discord机器人,它发送一条由随机选择的预定单词组成的消息。我尝试在第一个变量之后插入另一个变量,但这只会导致语法错误。顺便说一下,这是我的代码 @client.event async def on_message(message): if message.author == client.user: return if message.content.startswith('f!generate'): vari

我想用Discord.py创建一个Discord机器人,它发送一条由随机选择的预定单词组成的消息。我尝试在第一个变量之后插入另一个变量,但这只会导致语法错误。顺便说一下,这是我的代码

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('f!generate'):
      variable1 = [
        'test',
        'test2',
        'test3',]
      variable2 = [
        'test',
        'test2',
        'test3',]

      await message.channel.send((random.choice(variable1)),(random.choice(variable2)))

如何解决此问题?

Messageable.send
只接受1个位置参数,传递2个。只需将这两个字符串加在一起,就可以了

wait message.channel.send(random.choice(variable1)+random.choice(variable2))

是否有错误?机器人发送了什么?我想OP是以元组的形式传递的?他传递了两个元组