Ejemplo 1: discord.py ban
@commands.command() # uses command decorators, in this case inside a cog
@commands.has_permissions(ban_members=True) # only people that have permissions to ban users can use this command
async def ban(self, ctx, user: discord.Member, *, reason): # The person banning someone has to ping the user to ban, and input a reason. Remove self if you are outside a cog.
await ctx.guild.ban(user, reason=reason) # Bans the user.
await user.send(f"You have been banned in {ctx.guild} for {reason}") # Private messages user.
await ctx.send(f"{user} has been successfully banned.") # messages channel to tell everyone it worked
Ejemplo 2: discord.py mencionar al usuario
#discord.py rewrite
#python 3+
bot.command(name='pingme', help='pings the author of the message')
async def pingme(ctx):
#to get a member from a 'ctx' object is ctx.author
#from there its .mention will mention (ping) the user
#also there are others like .id
await ctx.send(ctx.author.mention)
Ejemplo 3: cómo mencionar a alguien discord.py
myid = '<@201909896357216256>'
await client.send_message(message.channel, ' : %s is the best ' % myid)
Ejemplo 4: Python discord menciona al usuario
await message.channel.send(message.author.mention)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)