【发布时间】:2021-06-27 21:07:29
【问题描述】:
这个问题主要是代码,因为我不知道发生了什么以及如何解决它......
我还将提供主文件。谢谢!
代码(看起来像这样;Microsoft Lens 不错,但不是很好):
import discord
from discord.ext.commands import CommandNotFound
from discord_slash import SlashCommand
def mixedCase(*args) :
total = []
for string in args:
a = map( ''. join,
itertools.product(*((c.upper(), c.lower( ))
for c in string) ) )
for x in list(a):
total.append(x)
return list(total)
client = commands.Bot(case_insensitive=True, command_prefix=mixedCase( "mc" ) )
slash = SlashCommand ( client, sync_commands=True, sync_on_cog_reload=True)
startTime = int(time.time( ))
client.main_startTime = startTime
class MyHelpCommand (commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination( )
e = discord.Embed(color=discord.Color.green( ), description='')
for page in self.paginator. pages:
e.description += page
e.set_footer (text="Need help? Do 'mcsupport to join the support server!")
await destination.send(embed=e)
client.help_command = MyHelpCommand( )
client.run(TOKEN)
错误:
Traceback (most recent call last):
File "Bot.py", line 127, in <module> client. run( "TOKEN" )
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/client.py", line 723, in run return future. result( )
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/client.py", line 702, in runner await self. start( *args,** kwargs )
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/client.py", line 666, in start await self. connect (reconnect=reconnect)
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/client.py", line 566, in connect await self.ws. poll_event( )
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/gateway.py", line 559, in poll_event await self. received_message(msg. data)
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/gateway.py", line 509, in received_message func (data)
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/state.py", line 490, in parse_message_crea te message = Message(channel=channel, data=data, state=self )
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/message. py", line 584, in _init ref. resolved = self.__class__(channel=chan, data=resol ved, state=state)
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/message.py", line 562, in _init self. stickers = [Sticker(data=data, state=state) for d ata in data. get( 'stickers', [])]
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/message.py", line 562, in <listcomp> self. stickers = [Sticker(data=data, state=state) for d ata in data. get( 'stickers', [])]
File "/home/quartz_i_warrior/.local/lib/python3.7/site-p ackages/discord/sticker.py", line 77, in _init_ self. pack_id = int(data['pack_id'])
KeyError: 'pack_id'
使用 Microsoft Lens 提取,我会尝试纠正遗漏的单词。
【问题讨论】:
-
为什么不能从编辑器中剪切和粘贴代码?这里的代码格式严重错误。
-
我不在家,所以我不得不通过手机访问 vps;我回来后会更新它。
标签: python python-3.x discord discord.py