@client.command(description="Pauses the current playing track. Can be resumed with `!resume`.",
brief="Pauses current track.",aliases=['PAUSE'])
async def pause(ctx):
guild_id = ctx.message.guild.id
players[guild_id].pause()
@client.command(description="Resumes the current playing track. Can only be used if current track has
been paused.",
brief="Resumes current track.",
aliases=['RESUME','continue','CONTINUE'])
async def resume(ctx):
guild_id = ctx.message.guild.id
players[guild_id].resume()
@client.command(description="Stops the current playing track.",
brief="Stops current track.",
aliases=['STOP'])
async def stop(ctx):
guild_id = ctx.message.guild.id
players[guild_id].stop()
当我尝试使用pause、stop和resume命令时,它会给出keyrerror。触发该错误的全部代码都在上面。错误是这样的:
忽略命令stop:Traceback(最近一次调用last)中的异常:文件“C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site packages\discord\ext\commands\core.py”,第83行,在wrapped ret=await coro(*args,**kwargs)文件“C:/Users/emirs/PycharmProjects/discordmasterbot/MASTERBOT.py”,第163行,停止玩家[guild\u id]。stop()键错误:708748879079932016
还有另一种类型的错误:
回溯(最近一次调用):文件“C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site packages\discord\ext\commands\bot.py”,第892行,调用等待ctx。命令调用(ctx)文件“C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site packages\discord\ext\commands\core.py”,第797行,在调用等待注入(*ctx.args,**ctx.kwargs)文件“C:\Users\emirs\PycharmProjects\discordmasterbot\venv\lib\site packages\discord\ext\commands\core.py”,第92行,在命令调用程序(exc)中来自exc的不和谐。外部命令。错误。CommandInvokeError:命令引发异常:KeyError:708748879079932016
KeyError表示找不到此对象的键。在这种情况下,玩家中不存在公会ID
708748879079932016
。
尝试在这里添加一个尝试/除块来捕获这些内容。
@client.command(description="Pauses the current playing track. Can be resumed with `!resume`.",
brief="Pauses current track.",aliases=['PAUSE'])
async def pause(ctx):
try:
guild_id = ctx.message.guild.id
players[guild_id].pause()
except KeyError:
# do something that adds the guild ID to players #
@client.command(description="Resumes the current playing track. Can only be used if current track has
been paused.",
brief="Resumes current track.",
aliases=['RESUME','continue','CONTINUE'])
async def resume(ctx):
try:
guild_id = ctx.message.guild.id
players[guild_id].resume()
except KeyError:
# do something that adds the guild ID to players #
@client.command(description="Stops the current playing track.",
brief="Stops current track.",
aliases=['STOP'])
async def stop(ctx):
try:
guild_id = ctx.message.guild.id
players[guild_id].stop()
except KeyError:
# do something that adds the guild ID to players #
我正在测试使用Discord为Discord机器人发送嵌入消息。js基本上是一个节点。用于与Discord的API交互的js模块。这是我用于bot发送嵌入消息的代码: 运行代码时,在Visual Studio代码IDE中出现以下错误: TypeError:(中间值). setTitle(...). setWriter(...). setColor(...). setdescription ptio
当我使用此代码时,它会正确打印所有内容,然后给我一个错误:KeyError:14425L代码: btw:
我已经创建了一个bot,它现在在我的discord服务器中,使用下面的代码。 我的问题是,一旦我在与bot不和谐的聊天中,我如何调用命令让bot运行代码,为用户列表收集csv?我不确定如何调用机器人,一旦它在聊天/服务器中获得列表。
我有错误,我检查了这个-discord bot-userinfo命令“IndentationError:unexpected indent”,但我不知道如何修复我的代码 此行出错- 这是我所有的功能
我有一个基本的不和谐机器人,我试图通过Heroku发布,因为我不能再在本地托管它了。应该提到它在本地托管在我的VM上时运行得非常好。当试图推动Heroku通过cli或git我得到一个错误,说: npm错误!cipm只能在安装软件包时安装软件包。json和包锁。json或npm收缩包装。json是同步的。继续之前,请使用更新锁定文件。远程:npm错误!远程:npm错误!远程:npm错误!缺失:enm
我做了很多关于如何阻止一个频道使用命令的研究,比如Rythm的黑名单,但是我没有找到,有人能帮我吗?