Reputation: 23
So I'm putting this in a Cog. I want to make it so that if the author is a specific person and they type anything, the bot will mention them and reply.
import discord
from discord.ext import commands
client = discord.Client()
class jtieu(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Bot 3 is ready.")
@commands.Cog.listener()
async def jtieu2(self, ctx):
if ctx.author == "CxS#3441" :
await ctx.channel.send(f"{ctx.author.mention} ok")
def setup(client):
client.add_cog(jtieu(client))
I'm not too sure if I'm supposed to use ctx.author.mention in this context, and I'm fairly new to how Cogs work in discord.py.
Upvotes: 2
Views: 175
Reputation: 2663
If you are creating a mention specifically for one user it might be a better idea to copy the user's id and use it instead of a nickname as it will work even when they change their name.
@commands.Cog.listener()
async def on_message(self, message):
if message.author.id == 1234567890: # example id
await message.channel.send(f"{message.author.mention} ok")
Remember that it requires intents.messages
.
Upvotes: 2