1
1
1uXeR2021-09-11 12:03:57
Python
1uXeR, 2021-09-11 12:03:57

I'm trying to temporarily ban tempban, what's wrong with my discord.py?

Here is my code, I need to change this line

if str(ctx.message.author.id) == '':
I need not to have a user ID, but several roles, the code itself is
ban_list = []
day_list = []
server_list = []

#This is a background process
async def countdown():
    await client.wait_until_ready()
    while not client.is_closed:
        await asyncio.sleep(1)
        day_list[:] = [x - 1 for x in day_list]
        for day in day_list:
            if day <= 0:
                try:
                    await client.unban(server_list[day_list.index(day)], ban_list[day_list.index(day)])
                except:
                    print('Error! User already unbanned!')
                del ban_list[day_list.index(day)]
                del server_list[day_list.index(day)]
                del day_list[day_list.index(day)]
               
#Command starts here
@client.command(pass_context = True)
@commands.has_permissions( manage_messages = True )
async def tempban(ctx,member:discord.Member, days = 1):
    if str(ctx.message.author.id) == '438617576499576835':
        try:
            await client.ban(member, delete_message_days=0)
            await ctx.send('User banned for **' + str(days) + ' day(s)**')
            ban_list.append(member)
            day_list.append(days * 24 * 60 * 60)
            server_list.append(ctx.message.server)
        except:
            await ctx.send('Ошибка! Пользователь не активен.')
    else:
        await ctx.send('У вас недостаточно прав')

client.loop.create_task(countdown())

If there are errors here, please tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alan Gibizov, 2021-09-11
@phaggi

The main mistake in violating the rules of the Toaster - did not use the search, there are a lot of questions about the implementation of a temporary ban.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question