0

I wanted to make a ticket system with a close command. But it doesn't work. I do get the embed message but when I react to the message nothing happens. I don't even get an error.

This is my code:

@bot.command(name='Close', aliases=['close'])
async def close(ctx):
    if ctx.message.channel.name.startswith('ticket'):
        msg = 'The ticket is closed. If you aren\'t done yet react to this message with , if you are react with ️'
        embed = discord.Embed(title='Closed ticket', description=msg)
        message = await ctx.send(content=None, embed=embed)
        await message.add_reaction('')
        await message.add_reaction('️')
        await ctx.message.channel.set_permissions(ctx.author, send_messages=False, read_messages=True)
        def check(reaction, user):
            return user == ctx.message.author and str(reaction.emoji) in ['', '️']
        reaction, user = await bot.wait_for('reaction_add', check=check)
        if reaction.emoji == '️':
            countdown = await ctx.send('**Ticket will be closed in 10 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 9 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 8 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 7 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 6 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 5 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 4 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 3 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 2 seconds**')
            await asyncio.sleep(1)
            await countdown.edit(content='**Ticket will be closed in 1 second**')
            await asyncio.sleep(1)
            await ctx.message.channel.delete()
            await user.send('**Ticket is deleted**')
        if reaction.emoji == '':
            await ctx.send('**Ticket reopened**')
            await ctx.message.channel.set_permissions(user, send_messages=True)
    else:
        await ctx.send('This isnt a ticket')
Nimantha
  • 6,405
  • 6
  • 28
  • 69
kezz
  • 107
  • 1
  • 2
  • 9
  • It works fine for me. Are you getting any errors? Which of the emojis does not work? – Dominik May 26 '21 at 09:46
  • Try to replace `if reaction.emoji == '️':` by `if str(reaction.emoji) == '️':`, because reaction.emoji may be few types and only one of them is string ([reference](https://discordpy.readthedocs.io/en/latest/api.html#discord.Reaction.emoji)) – Baptiste May 26 '21 at 09:46
  • @Dominik none of them works. And i get no errors – kezz May 26 '21 at 09:49
  • @Baptiste Tried that but doesn't work for me – kezz May 26 '21 at 09:49
  • Have you imported the `members` Intent or something? I do not know if that is somehow connected to each other. – Dominik May 26 '21 at 09:51
  • Are you sure that you first condition returns True? Can you verify this? – Baptiste May 26 '21 at 09:58
  • ```intent = discord.Intents(members=True, messages=True, guilds=True, presences=True, dm_messages=True) ``` These are my intends – kezz May 26 '21 at 09:59
  • I get the embed with the emojis. That works its only the reactions that dont work – kezz May 26 '21 at 10:00
  • OK, so try to print you reaction.emoji to see what is returned – Baptiste May 26 '21 at 10:01
  • ```def check(reaction, user): return user == ctx.message.author and str(reaction.emoji) in ['', '️'] reaction, user = await bot.wait_for('reaction_add', check=check) print(reaction.emoji)``` I have it like this and i dont get anything – kezz May 26 '21 at 10:07
  • Maybe instead of using emojis in your code use their unicodes? like this `str(reaction.emoji) in ['\U0001f5d1', '\U0001f513']`. – loloToster May 26 '21 at 10:42
  • nope doesn't work ): – kezz May 26 '21 at 11:03

0 Answers0