Discord.py bot not sending the whole message

I have a discord bot that when I enter .members, it answers back with all the list of member ids.

This is my code:

mainbot = commands.Bot(command_prefix = ".")  @mainbot.command() @commands.guild_only() async def member(ctx):     for members in ctx.guild.members:         ids = members.id      await ctx.channel.send(ids)  mainbot.run(token_test) 

However, it doesn’t send back all the ids. Instead, it sends back the last id in the list.

What I’m I doing wrong? Python 3.8

Add Comment
1 Answer(s)

Your command always rewrites ids. You should make ids a string, and then add each member’s id:

mainbot = commands.Bot(command_prefix = ".")  @mainbot.command() @commands.guild_only() async def member(ctx):     ids = ''     for members in ctx.guild.members:         ids += '{}, '.format(members.id)               # += is the change      await ctx.channel.send(ids)  mainbot.run(token_test) 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.