Skip to content Skip to sidebar Skip to footer

How Can I Send This List As One Message In Discord.py?

I just tried adding a listrole command on my discord bot which lists every user with a certain role. However I can't seem to find a solution where my bot sends the whole list as on

Solution 1:

Define your memberlist before the loop, and append to it. Then, join all the items in that list into one long string separated by newlines, and send it after the loop completes:

memberlist = []
for member in members:
    memberlist.append(f"{member.display_name}#{member.discriminator}")
await ctx.send('\n'.join(memberlist))

Post a Comment for "How Can I Send This List As One Message In Discord.py?"