Home>
@ clan.command ()
    async def profile (self, ctx):
        author= ctx.message.author
        clan_id= cur.execute (f'SELECT ClanId FROM UserClans WHERE UserId= {author.id} '). fetchone ()
        cur.execute (f'SELECT UserName FROM UserClans WHERE {clan_id [0]} ')
        users= cur.fetchall ()
        l= []
        l.append (users)
        return print (l)

I need to display all users of the clan, but this way displays only the first in the list. Is there a way to output everyone without a loop?

  • Answer # 1

    append ()adds only one element

    To add multiple elements useextend ()

    @ clan.command ()
        async def profile (self, ctx):
            author= ctx.message.author
            clan_id= cur.execute (f'SELECT ClanId FROM UserClans WHERE UserId= {author.id} '). fetchone ()
            cur.execute (f'SELECT UserName FROM UserClans WHERE {clan_id [0]} ')
            users= cur.fetchall ()
            l= []
            l.extend (users) # one change
            return print (l)
    
  • Answer # 2

    append ()adds only one element

    To add multiple elements useextend ()

    @ clan.command ()
        async def profile (self, ctx):
            author= ctx.message.author
            clan_id= cur.execute (f'SELECT ClanId FROM UserClans WHERE UserId= {author.id} '). fetchone ()
            cur.execute (f'SELECT UserName FROM UserClans WHERE {clan_id [0]} ')
            users= cur.fetchall ()
            l= []
            l.extend (users) # one change
            return print (l)