Having Trouble Making A Discord Bot That Direct Messages @mentioned User
trying to create a command for my bot where you can type /ping @user, and it then dm's mentioned user, as well as replies in chat with 'pong' heres what i have so far: async def cm
Solution 1:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='/')
@bot.command()asyncdefping(user: discord.User):
await bot.send_message(user, "Pong")
await bot.say("Pong")
@ping.errorasyncdefping_error(ctx, error):
# You might have to play with the arguments here depending on your version of discord.pyifisinstance(error, commands.BadArgument):
await bot.say("Could not find that user.")
I've tried to write the above for "async" branch, but you should know that there is also a "rewrite" branch of discord.py
that is more current and has better documentation, especially when it comes to the commands
extension.
Did you write safe_send_message
? I don't see it documented anywhere.
Solution 2:
This is my warn command. Try to use this as a template.
@client.command(pass_context = True)@commands.has_permissions(kick_members=True)asyncdefwarn(ctx, userName: discord.User, *, message:str):
await client.send_message(userName, "You have been warned for: {}".format(message))
await client.say(":warning: __**{0} Has Been Warned!**__ :warning: Reason:{1} ".format(userName,message))
pass
Post a Comment for "Having Trouble Making A Discord Bot That Direct Messages @mentioned User"