Answer the question
In order to leave comments, you need to log in
How to display each invite from the guild.invites list in discord.py?
I need to send each invite from the list of server invites to the chat. I tried to do this with "for i in guild.invites" but when I ran the command (not on the initial run) I got an error:
Ignoring exception in command gl:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "<string>", line 18, in gl
TypeError: 'coroutine' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/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: 'coroutine' object is not iterable
/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.8/asyncio/events.py:81: RuntimeWarning: coroutine 'Guild.invites' was never awaited
self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
@bot.command()
async def gl(ctx):
il = ctx.guild.invites() #Берем список инвайтов в сервере и посещаем в il
for i in il:
emb = discord.Embed(title="IL", type="rich", colour=discord.Color.dark_blue()) #Создаем эмбед для красоты вывода
emb.add_field(name="SCR:",value=f"{i}")
await ctx.send(embed=emb) #Отправляем сообщение
Answer the question
In order to leave comments, you need to log in
By the rules of the language,
it tries to iterate the method object itself, not what it returns.
Maybe you should:
Maybe that's not the point - I don't know what the method returns there. But from what you have shown, I can only assume this. for i in guild.invites:
for i in guild.invites():
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question