【发布时间】:2021-01-07 06:08:29
【问题描述】:
我添加了用于在 Discord 中创建机器人的代码。我已经调试了一个错误,现在又遇到另一个错误,我无法理解。
代码如下:
TOKEN = 'XXXXXXXXXXXXXXXXXXXXX'
client = discord.Client()
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
if message.content.startswith(':help'):
msg = 'Hello! I am Pytho Memer, a meme bot, at your service. You can make me get some nice memes for you.' \
'You can use the following command for it:' \
'' \
'```:meme```' \
'' \
'This command will generate a meme for you.' \
'Hope you will enjoy this. :)'.format(message)
await client.send_message(message.channel, msg)
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)
但我有一个 TraceBack 如下:
File "C:/Users/Bhavyadeep Yadav/Desktop/Python Projects/Pytho Memer/bot_main.py", line 33, in <module>
client.run(TOKEN)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 466, in run_until_complete
return future.result()
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 491, in start
yield from self.connect()
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 448, in connect
yield from self.ws.poll_event()
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\gateway.py", line 431, in poll_event
yield from self.received_message(msg)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\gateway.py", line 390, in received_message
func(data)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\state.py", line 509, in parse_guild_create
server = self._get_create_server(data)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\state.py", line 483, in _get_create_server
server._from_data(data)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\server.py", line 218, in _from_data
self._sync(guild)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\server.py", line 250, in _sync
channel = Channel(server=self, **c)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\channel.py", line 89, in __init__
self._update(**kwargs)
File "C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\channel.py", line 116, in _update
self._permission_overwrites.append(Overwrites(**overridden))
TypeError: __new__() got an unexpected keyword argument 'deny_new'
Task was destroyed but it is pending!
task: <Task pending coro=<ConnectionState._delay_ready() running at C:\Users\Bhavyadeep Yadav\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\state.py:173> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x0309F6B0>()]>>
Process finished with exit code 1
请帮助我解决这个问题。类型错误对我来说太难理解了。 我在 Python 中不是那么好,所以我不能自己调试它。 希望你能帮助我。
【问题讨论】:
标签: python python-3.x python-2.7 discord discord.py