Reputation: 13
I would like that when a member clicks on a certain reaction, the bot create a channel but it doesn't work :
My code :
@bot.event
async def on_raw_reaction_add(payload):
reaction = (u"\U0001F4E9")
if reaction == reaction :
channel = await payload.create_text_channel('Tickets', overwrites=None, reason=None)
return channel
The Error :
AttributeError: 'RawReactionActionEvent' object has no attribute 'create_text_channel'
Upvotes: 0
Views: 882
Reputation: 4225
You can by getting the guild from guild_id
@bot.event
async def on_raw_reaction_add(payload):
if str(payload.emoji) == "📩":
guild = bot.get_guild(payload.guild_id)
channel = await guil.create_text_channel('Tickets')
return channel
Upvotes: 0
Reputation: 2415
In this case, it's probably not needed to use a raw_reaction_add
, instead you can just use a on_reaction_add
event which would always wait for a user to react with your specified emoji
However, it's not like you can just pass ctx, so you have to use reaction
as your argument, then the message channel. You can define the guild simply with reaction.message.guild
.
Here's a simple example of using this, make sure to add other changes or checks eg. Checking if the reaction was in a specified guild or message id.
@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == '📩':
guild = reaction.message.guild
await guild.create_text_channel('Tickets', overwrites=None, reason=None)
await reaction.message.channel.send('Created a ticket!')
The error in your code is also explanatory, AttributeError: 'RawReactionActionEvent' object has no attribute 'create_text_channel
simply means payload
hasn't got an attribute for create_text_channel
, however including message
would allow this. Raw reaction add isn't needed in this case
Upvotes: 1