ASOwnerYT
ASOwnerYT

Reputation: 77

discord.py - Trying to make command that only works for a specific user

I am trying to make a command that makes my Discord bot repeat what I say. However, I only want it to work for me. When I had (ctx, *, message) as my arguments, there's an error similar to "Message not defined". But when the only argument is (message), it can print the message author. But now when I run the command, the bot says in the Discord chat this error: <discord.ext.commands.context.Context object at 0x0000014E1DE3D940>

Here is my code:

@client.command()
async def say(message):
    if str(message.author) == "ASOwnerYT#7799":
        await message.channel.send(str(message))
else:
    print(f'{message.author} tried to use the say command!')

Upvotes: 0

Views: 2566

Answers (1)

ASOwnerYT
ASOwnerYT

Reputation: 77

Nevermind, thanks to the support in the Python discord server, I fixed it:

@client.command()
@commands.is_owner()
async def say(ctx, *, message):
    await ctx.send(message)

Upvotes: 5

Related Questions