我正在尝试使用 create_custom_emoji 从图像中创建表情符号,但我收到了“issing 1 required positional argument: 'self'”
I'm trying to create an emoji out of an image with create_custom_emoji and I'm getting a 'issing 1 required positional argument: 'self''
@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 无关。我查阅了文档,它应该完全按照需要进行格式化。对不起,如果这是一个愚蠢的问题,但我对这个问题一头雾水。
您尝试创建表情符号 class 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)
@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 无关。我查阅了文档,它应该完全按照需要进行格式化。对不起,如果这是一个愚蠢的问题,但我对这个问题一头雾水。
您尝试创建表情符号 class 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)