There's a few ways of doing this
From user ID
@client.command()
async def DM(ctx, id: int, *, content):
user = client.get_user(id)
await user.send(content)
# Invoking
# $DM 123123123123123 something here
From user name#discriminator
@client.command()
async def DM(ctx, username, *, content):
name, discriminator = username.split("#")
user = discord.utils.get(ctx.guild.members, name=name, discriminator=discriminator)
await user.send(content)
# Invoking
# $DM example#1111 something here
With user mentions, ID's, names, nicknames (best option imo)
@client.command()
async def DM(ctx, member: discord.Member, *, content):
await member.send(content)
# Invoking
# $DM @example#1111 something here
# $DM 1231231231231 something here
# $DM example#1111 something here
Also make sure you enabled intents.members
, for more info look at one of my previous answers
PS: You need to use commands.Bot
in order for all of this to work, not discord.Client