简体   繁体   中英

Suggest command discord.py

I am making a discord bot in discord.py , and I want my members to be able to suggest features to me, and of course they can't just say it in the server, I probably wouldn't even know. So I want the bot to DM message it to me, lets say my discord is DiscordUser#1234 and another user used the suggest command, the other user is AnotherUser#4321 . When AnotherUser used the suggest command, it would work in this format: (prefix) suggest (Suggestion) . So DiscordUser would recieve AnotherUser#4321 has suggested (Suggestion)

I got the command working and everything is fine, except i don't know how to DM a specific person

This is the easiest way I've been able to do this, hope it helps!

@client.command()
async def suggest(ctx, *, text):
    user = await client.fetch_user("<your_id_here>")
    await user.send(f"""{ctx.author.mention} has suggested {text}""")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM