Problems with a serverinfo command

Viewed 68
n = [role.mention for role in ctx.guild.roles]
        u = n[len(n) - 1]
        ab = n[0]

Above, the variable n is supposed to create a list of roles in the server which it does, and the variable u is used to get a Server's highest positioned role which it does too.

the variable ab, however in any case should return @everyone but it returns @@everyone any way I can fix this? or somehow replace @@everyone with @everyone

I tried the following:
ab = n[0]
if ab == f"@<@{ctx.guild.default_role.id}>":
           ab = f"<@{ctx.guild.default_role.id}>"

however, it didn't work. Any help would be appreciated enter image description here

enter image description here

1 Answers

This happens because the default name of the role is already "@everyone", so when you retrieve the mention it adds another "@" to it, becoming @@everyone". What you could do to solve this would be replacing this with "everyone" like this:

    n = [role.mention for role in ctx.guild.roles[1:]]  # Ignore the @everyone
    n.insert(0,'@everyone')  # Add string @everyone at the beginning
    # Here goes the rest of your code
Related