Reputation: 3
The intention was to when -rickroll is used and the bot is pinged it should say no u if not | update-> the user is the one who has to be pinged.
The it should send a gif and say (@the pinged) has been rickrolled lol
if user.id != 878176818564317184:
await ctx.send('https://tenor.com/view/rick-astley-rick-roll-dancing-dance-moves-gif-14097983')
await ctx.send(user)
await ctx.send('has been rickrolled lol')
else:
await ctx.send('No u')```
Upvotes: 0
Views: 127
Reputation: 77
I wrote this:
@bot.event
async def on_message(message):
if message.author == bot.user:
return
#refering to the message sent in discord and chaning it to lower case
msg = message.content.lower().replace(' ', '')
if msg.startswith('!help'):
if message.author.id != 878176818564317184:
await message.channel.send('''https://tenor.com/view/rick-astley-rick-roll-dancing-dance-moves-gif-14097983''')
await message.channel.send(f'''{message.author.mention} you have been rickrolled lol''')
else:
await message.channel.send('No u')
Upvotes: 1
Reputation: 117
Supposing ctx
is the first parameter of the discord.py on_message
event, then the variable ctx
is an instance of the discord.message.Message class which contains no method called send
, thus ctx.send(user)
is not going to work.
Assuming you want your bot to respond in the same text channel the message was sent to, you can take advantage of the channel attribute from the Message class, which contains a send
method that will allow you to send messages.
Therefore a possible solution would be:
await ctx.channel.send("Your message")
A different but less usual approach would consist on the usage of the Message.reply method. It would be like this:
await ctx.reply("Hey, I'm replying to your msg!")
The biggest difference between the two would be that the second uses Discord's reply feature, hence the user who sent the message in first place would be pinged.
You can find this and more information in the official documentation of the library.
Upvotes: 0