Python – DM a User Discord Bot

The easiest way to do this is with the discord.ext.commands extension. Here we use a converter to get the target user, and a keyword-only argument as an optional message to send them: from discord.ext import commands import discord bot = commands.Bot(command_prefix=’!’) @bot.command(pass_context=True) async def DM(ctx, user: discord.User, *, message=None): message = message or “This Message … Read more