I am making a Discord Bot in Python(3.7.3) and I would like to send a dm to a user with an invite link to the server. This is my code:
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>
I have a discord.member.Member() class. And I would like to make an invite link to a channel(a have a channel object if that's needed) and dm it to a user. Any help is appreciated, thanks!
Thanks to everyone who helped me I have found a solution.
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)
Here is the documentation create_invite documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With