Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make an annoucement command that can only triggered by me in dm (nextcord)

So, I am going to make an annoucement command that only can triggered by me and by dm the bot

@client.command(pass_context=True)
@commands.has_any_role('BasicLolGaming', 'MODERATOR', 442186820977950720)
async def pemberitauan(ctx):
    embed= nextcord.Embed(
        color= nextcord.Color.dark_red()
    )
    embed.set_author(name='Kentod', icon_url='https://cdn.discordapp.com/avatars/707853874895126598/fd92dfd8c389bf9f2ba7a756df4b2681.webp?size=48')
    embed.set_image(url='https://cdn.discordapp.com/attachments/865242702668759100/902717752605806612/unknown.png')

    channel = client.get_channel(803585009692835851)
    await channel.send(embed=embed)

This code works for me only if i write it the command in the server. but, i want can triggered the code by dm the bot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use check @commands.is_owner() check instead of @commands.has_any_role('BasicLolGaming', 'MODERATOR', 442186820977950720). And add owner_ids=[your_id] kwarg in your client initialization.
For example

client = Bot(command_prefix="!", owner_ids=[your_id])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading