我用 Python 制作了一个简单的 Discord 机器人,它在运行时显示错误

时间:2021-05-08 12:33:45

标签: python discord discord.py

所以我用 Python 制作了一个非常简单的 Discord 机器人。

import asyncio 
import discord

client = discord.Client()

token = 'my token'


@client.event
async def on_ready():   
    print(client.user.name)
    print(client.user.id)
    
@client.event
async def on_message(message):
    if message.content.startswith('hi'):
        channel = message.channel
        await channel.send('hello!')

client.run(token)

这是它的代码。

但是,每当我尝试运行它时,都会创建如下错误消息:

  File "C:/Users/erick/Desktop/디스코드봇/음악봇.py", line 20, in <module>
    client.run(token)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 640, in run
    return future.result()
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 585, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 499, in connect
    await self._connect()
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 463, in _connect
    await self.ws.poll_event()
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 471, in poll_event
    await self.received_message(msg)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 425, in received_message
    func(data)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 750, in parse_guild_create
    guild = self._get_create_guild(data)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 725, in _get_create_guild
    guild._from_data(data)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\guild.py", line 297, in _from_data
    self._sync(guild)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\guild.py", line 326, in _sync
    self._add_channel(VoiceChannel(guild=self, data=c, state=self._state))
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 553, in __init__
    self._update(guild, data)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py", line 584, in _update
    self._fill_overwrites(data)
  File "C:\Users\erick\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 294, in _fill_overwrites
    self._overwrites.append(_Overwrites(id=overridden_id, **overridden))
TypeError: __new__() got an unexpected keyword argument 'deny_new'

我不知道为什么......有人可以帮忙吗?

当我运行它时,机器人上线大约 0.1 秒,然后它关闭并显示此错误消息。

大约一年前,我制作了类似的简单机器人,它们运行得非常好。 是更新问题之类的吗?

请帮忙:(

0 个答案:

没有答案