如何解决我正在尝试使用 create_custom_emoji 从图像中创建表情符号,但我收到了“正在发送 1 个必需的位置参数:‘自我’”
@bot.command()
async def createemoji(ctx):
with open('Racoon.jpg','rb') as f:
data = f.read()
await discord.Guild.create_custom_emoji(name='Raccoon',image=data)
这是代码,图片文件在main.py目录下。 这是完整的错误:
Ignoring exception in command createemoji:
Traceback (most recent call last):
File "C:\Users\imnap\Interpreter\lib\site-packages\discord\ext\commands\core.py",line 85,in wrapped
ret = await coro(*args,**kwargs)
File "C:\Users\imnap\PycharmProjects\Cyrene\main.py",line 235,in createemoji
await discord.Guild.create_custom_emoji(name='Raccoon',image=data)
TypeError: create_custom_emoji() missing 1 required positional argument: 'self'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\imnap\Interpreter\lib\site-packages\discord\ext\commands\bot.py",line 939,in invoke
await ctx.command.invoke(ctx)
File "C:\Users\imnap\Interpreter\lib\site-packages\discord\ext\commands\core.py",line 863,in invoke
await injected(*ctx.args,**ctx.kwargs)
File "C:\Users\imnap\Interpreter\lib\site-packages\discord\ext\commands\core.py",line 94,in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError:
create_custom_emoji() missing 1 required positional argument: 'self'
我查阅了几十篇与我的非常相似的帖子,但其中大部分与 discord.py 无关。我查了文档,应该完全按照需要格式化。对不起,如果这是一个愚蠢的问题,但我对这个问题不知所措。
解决方法
您尝试为课程 discord.Guild 创建表情符号
您真正想做的是将表情添加到使用该命令的公会
@bot.command()
async def createemoji(ctx):
guild = ctx.guild
with open('Racoon.jpg','rb') as f:
data = f.read()
await guild.create_custom_emoji(name='Raccoon',image=data)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。