Sco*_*t10 3 python discord discord.py
我正在用Python(3.7.3)制作一个Discord Bot,我想向用户发送一条带有服务器邀请链接的DM。这是我的代码:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=config.get_config, description='Thou Holy Bot')
@bot.command(name='dm',pass_context=True)
async def dm(ctx, *, argument):
<code here>
Run Code Online (Sandbox Code Playgroud)
我有一个discord.member.Member() 类。我想创建一个到频道的邀请链接(如果需要的话,有一个频道对象)并将其发送给用户。任何帮助表示赞赏,谢谢!
感谢所有帮助我的人,我找到了解决方案。
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!', description='Bot')
@bot.command(name='dm',pass_context=True)
async def dm(ctx, *argument):
#creating invite link
invitelink = await ctx.channel.create_invite(max_uses=1,unique=True)
#dming it to the person
await ctx.author.send(invitelink)
Run Code Online (Sandbox Code Playgroud)
这是文档create_invite 文档
归档时间: |
|
查看次数: |
7304 次 |
最近记录: |