Z
Z
zhabaa2022-03-11 21:18:17
Python
zhabaa, 2022-03-11 21:18:17

Is it possible to create an exception for a user in a discord bot?

i want the command to perform a specific action only for a specific user, it doesn't work

@bot.command() #рандомайзер 
async def random(ctx):
    author = ctx.message.author
    
    if author == 'wsip#2534':
        await ctx.send(f'{author.mention}, Ты выбил 6 ')
    else:
        await ctx.send(f'{author.mention}, Ты выбил {randint(1, 6)}')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alan Gibizov, 2022-03-12
@zhabaa

There is a feeling that there is something in the author that is not as expected. Perhaps there is no line at all.
Is this exactly the author = ctx.message.authorright way to refer to the object you're looking for? .author is by any chance not a method you are calling as a parameter? Check the type of the returned object, is it exactly a string?

U
Un1code, 2022-03-12
@Un1code

@bot.command() #рандомайзер 
async def random(ctx):
    wsip = ctx.message.author
    
    if wsip.id == 'твой id':
        await.ctx.send(f'{wsip.mention}, Ты выбил 6 ')
    else:
        await ctx.send(f'{wsip.mention}, Ты выбил {randint(1, 6)}')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question