Discord.py 如何向提到的用户发送 PM?
Discord.py How can I send a PM to the mentioned user?
所以我做了这个 Ban 命令,但我想对其进行编码,以便在我禁止某人时发送 DM。我尝试了不同类型的代码,但其中 none 行得通。我很确定这只是我必须更改的一个词,但您仍然可以看一下吗?
代码(也在Cog里面):
import discord
from discord.ext import commands
class Ban(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member : discord.Member, *, reason = None):
await member.ban(reason = reason)
ban = discord.Embed(title='Ban Hammer Has Spoken! :boom:', description=f'**Moderator:** {ctx.author}\n **User Banned:** {member}\n **Reason:** {reason} ', color=0xbd2929)
ban.set_author(name="Moderating Action", icon_url=ctx.author.avatar_url)
await ctx.channel.send(embed=ban)
dmban = discord.Embed(title=f'Ban Information From {ctx.guild}', discription=f'**Moderator:** Unknown\n **User Banned:** {member}\n **Reason:** {reason}', color=0xbd2929)
await ctx.user.send(embed=dmban)
def setup(client):
client.add_cog(Ban(client))
被禁止的用户是member
arg,只需执行
await member.send(...)
所以我做了这个 Ban 命令,但我想对其进行编码,以便在我禁止某人时发送 DM。我尝试了不同类型的代码,但其中 none 行得通。我很确定这只是我必须更改的一个词,但您仍然可以看一下吗?
代码(也在Cog里面):
import discord
from discord.ext import commands
class Ban(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
@commands.has_permissions(ban_members = True)
async def ban(self, ctx, member : discord.Member, *, reason = None):
await member.ban(reason = reason)
ban = discord.Embed(title='Ban Hammer Has Spoken! :boom:', description=f'**Moderator:** {ctx.author}\n **User Banned:** {member}\n **Reason:** {reason} ', color=0xbd2929)
ban.set_author(name="Moderating Action", icon_url=ctx.author.avatar_url)
await ctx.channel.send(embed=ban)
dmban = discord.Embed(title=f'Ban Information From {ctx.guild}', discription=f'**Moderator:** Unknown\n **User Banned:** {member}\n **Reason:** {reason}', color=0xbd2929)
await ctx.user.send(embed=dmban)
def setup(client):
client.add_cog(Ban(client))
被禁止的用户是member
arg,只需执行
await member.send(...)