Discord bot的问题| charmap'编解码器无法编码字符

时间:2019-04-23 19:43:12

标签: python windows bots discord

我正在尝试使用python创建一个不和谐的机器人,我的问题是,我希望在通道名称中添加一些表情符号,并且当我添加了表情符号时,命令停止了工作!

Windows 7 Python 3.7.2

代码:

    channel = client.get_channel(569684483985375242)

    if channel is not None:
        embed=discord.Embed(title="Reage com :white_check_mark: para vermos que não és um bot!", color=0xffff00)
        embed.set_author(name="Verifica-te", icon_url="https://media.discordapp.net/attachments/495260177457741826/569559242382639135/LEIGUINHOS.png?width=644&height=644")
        await channel.send(embed=embed)

错误:

UnicodeEncodeError: 'charmap' codec can't encode character '\u2714' in position 29: character maps to <undefined>

试图解决: 代码:

    channel1 = client.get_channel(569684483985375242)
    channel = channel1.encode('cp850','replace').decode('cp850')
    if channel is not None:
        embed=discord.Embed(title="Reage com :white_check_mark: para vermos que não és um bot!", color=0xffff00)
        embed.set_author(name="Verifica-te", icon_url="https://media.discordapp.net/attachments/495260177457741826/569559242382639135/LEIGUINHOS.png?width=644&height=644")
        await channel.send(embed=embed)

错误:


AttributeError: 'TextChannel' object has no attribute 'encode'

然后我更改了这一行:

   channel1 = client.get_channel(569684483985375242)

   channel1 = str(client.get_channel(569684483985375242))

它给出了一个错误:

AttributeError: 'str' object has no attribute 'send'

有人可以解释为什么会发生这种情况,我该如何解决?谢谢您,抱歉我的英语错误!

0 个答案:

没有答案