Discord.py 在消息中添加内容

时间:2021-01-25 18:57:41

标签: discord discord.py

我在我想要的地方有这个代码,所以当我说 p!serverlist 时,它会打印出它所在的服务器。我不知道如何在我的变量 a 中“附加”服务器。

if message.content.startswith('p!serverlist'):
        a = ''
        e = 0
        await message.channel.send('**Servers that I am in**')
        for guild in client.guilds:
            await a.append(f' `{guild.name}` ')
            e += 1
        await message.channel.send(a)
        await message.channel.send('**I am in ' + str(e) + ' servers!**')```

1 个答案:

答案 0 :(得分:2)

你没有.append它。您只需使用 += 运算符。

a += f' {guild.name} '