Answer the question
In order to leave comments, you need to log in
How to send messages to a discord bot?
There are very serious problems. I want the bot to automatically send a PM message to the person who was unbanned with the message that he can return to the server again. If I write ctx.user.send
, an error is thrown that this is a subclass, etc., etc. (I know that this is a subclass like author)
Here is the code itself:
#unban
@commands.has_permissions(administrator = True)
@client.command(pass_context = True)
async def unban(ctx, *, member):
await ctx.channel.purge(limit = 1)
banned_users = await ctx.guild.bans()
for ban_entry in banned_users:
user = ban_entry.user
await ctx.guild.unban(user)
await ctx.send(F"Добро пожаловать. Снова. {user.mention}")
await ctx.user.send("Божество услышало твой зов, теперь снова можешь вернуться :3") #https://discord.gg/
return
Answer the question
In order to leave comments, you need to log in
Just use the "send" method on the user
@commands.has_permissions(administrator = True)
@client.command()
async def unban(ctx, *):
await ctx.message.delete() # Для удаления сообщения с командой, если в оригинале подразумевалось это
banned_users = await ctx.guild.bans()
for ban_entry in banned_users:
user = ban_entry.user
await ctx.guild.unban(user)
await ctx.send(f"Добро пожаловать. Снова. {user.mention}")
await user.send("Божество услышало твой зов, теперь снова можешь вернуться :3")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question