Someone
Someone

Reputation: 84

Blacklist (variable) not working discord.py

I just made blacklist in my bot, and still I can use bot even though I blacklisted myself. This is my code:

BLACKLIST = ["my ID"]

@bot.command()
async def testblacklist(ctx):
  if ctx.author.id in BLACKLIST:
    await ctx.send("U r on blacklist!")
  else:
    await ctx.send("Test")

Can anyone help me with this? There aren't any errors in console and bot sends "Test"

Upvotes: 0

Views: 83

Answers (1)

loloToster
loloToster

Reputation: 1415

That's because in BLACKLIST your id is a str and ctx.author.id is int. You have 2 options:

  1. replace:
if ctx.author.id in BLACKLIST:

with:

if str(ctx.author.id) in BLACKLIST:
  1. Put int as your id in BLACKLIST

Upvotes: 1

Related Questions