#python #python-3.x #discord #discord.py #discord.py-rewrite
#python #python-3.x #Discord #discord.py #discord.py-переписать
Вопрос:
Я не знаю, где ошибка. У меня есть команда GIveAway, которая работает, если я набираю что-либо в обычном строковом формате, но если я попытаюсь внедрить его снова. это не работает. помогите, пожалуйста?:
Код:————————————————————————————————
@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def gstart(ctx):
await ctx.send("Answer These Questions you only have 25 Seconds!")
questions = ["Which channel should it be hosted in?",
"What should be the duration of the giveaway? (s/m/h/d)",
"What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for("message", timeout=25.0, check=check)
except asyncio.TimeoutError:
await ctx.send("You didn't answer in time, Please be faster! Retard")
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You did not mention a channel properly, Do it like this {ctx.channel.mention} next time.")
return
channel = client.get_channel(c_id)
time = convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer the time with a proper unit. Use (s/m/h/d).")
return
elif time == 2:
await ctx.send(f"The time must be an intger (number). Please enter in a number.")
return
prize = answers[2]
await ctx.send(f"The GiveAway will be in {channel.mention} and will last {answers[1]} seconds!")
embed = discord.Embed(title = "GiveAway! 🎉", description = f"{prize}", color = random.choice(mycolor))
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
embed.set_footer(text = f"Ends {answers[1]} from now!")
my_msg = await channel.send(embed=embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await channel.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
winner = random.choice(users)
em = discord.Embed(title=f"We have a GiveAway winner", color = random.choice(mycolor)) #here
em.set_author(name=f"Congrats {winner.mention}") #here
em.add_field(name=f"{winner.mention} WON:", value=f"{prize}!") #here
em.set_footer(text=f"Organized by {ctx.author.mention}", icon_url=ctx.author.avatar_url) #here
await ctx.send(em=em) #so this doesn't work but if I do channel.send("example") it works
Ошибка:————————————————————————————
Ignoring exception in command gstart:
Traceback (most recent call last):
File "C:UsersalmajAppDataLocalProgramsPythonPython39libsite-packagesdiscordextcommandscore.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:UsersalmajOneDriveDocuments3mbotmain codembot.py", line 619, in gstart
await ctx.send(em=em)
TypeError: send() got an unexpected keyword argument 'em'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersalmajAppDataLocalProgramsPythonPython39libsite-packagesdiscordextcommandsbot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "C:UsersalmajAppDataLocalProgramsPythonPython39libsite-packagesdiscordextcommandscore.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:UsersalmajAppDataLocalProgramsPythonPython39libsite-packagesdiscordextcommandscore.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() got an unexpected keyword argument 'em'
Я пробовал ctx.отправить канал.отправить ctx.channel.send…. Ничего не работает
Ответ №1:
Это не em
так embed
await ctx.send(embed=em)