sorry that this is probably rather easy to fix (I don't really understand the docs) But, I want a channel to be opened, so only the user and mods can see it. It will be opened when the user adds a reaction to the message, the reaction will then be deleted (leaving just the bot's reaction) Currently, my code is:
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
if reaction.emoji == '📩':
if user.channel.id == 850622999577231370:
await message.remove_reaction("📩", user)
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
guild.me: discord.PermissionOverwrite(read_messages=True)
}
n = random.randomint(1, 1000)
await guild.create_text_channel(f'Ticket {n}', overwrites=overwrites, categoty="Tickets")
else:
pass
else:
pass
It doesn't seem to run, since there is no error message, but no channels are created either
A few things I noticed:
random.randomint
does not exist, it must be random.randrange
.guild
in the provided code, we'll just use user.guild
instead.if reaction.message.channel.id
and not if user.channel.id
, that makes little sense here.Here is a possible new code:
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
if reaction.emoji == '📩':
print("Reaction")
if reaction.message.channel.id == Your_Channel_ID:
await reaction.message.remove_reaction("📩", user)
guild = user.guild # We get the guild
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
guild.me: discord.PermissionOverwrite(read_messages=True)
}
n = random.randrange(1, 1000) # We choose a number from randrange 1-1000
await guild.create_text_channel(f'Ticket {n}', overwrites=overwrites, categoty="Tickets")
else:
pass
else:
pass