简体   繁体   English

不和谐.py | 当我发送特定消息时,如何制作一个提供角色的不和谐机器人?

[英]Discord.py | How to make a discord bot that gives roles when i send a specific message?

I tried this:我试过这个:

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if message.content == 'give me admin':
        role = get(message.guild.roles, name='role')
        await message.author.add_roles(message.author, role) 

but im getting this error:但我收到这个错误:

discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role

i swear i typed the name of the role correctly我发誓我正确输入了角色名称

According to the docs, member.add_roles doesn't need the message.author argument.根据文档, member.add_roles不需要message.author参数。 If you remove that it should work fine.如果你删除它应该可以正常工作。

await message.author.add_roles(role) 

https://discordpy.readthedocs.io/en/master/api.html?highlight=add_roles#discord.Member.add_roles https://discordpy.readthedocs.io/en/master/api.html?highlight=add_roles#discord.Member.add_roles

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Discord.py 如何让机器人向特定频道发送消息 - Discord.py How to make a bot send message to a specific channel 如何让我的 discord.py 机器人删除在特定频道上发送的每条消息? - How can I make my discord.py bot delete every message send on a specific channel? Discord.py 使机器人在按键时向特定频道发送消息 - Discord.py make bot send a message to specific channel on keypress discord.py 如何让机器人在特定用户类型时发送消息? - discord.py how do I get a bot to send a message when a specific user types? Discord Bot 不发送特定消息 | discord.py - Discord Bot doesn't send specific message | discord.py discord.py 如何让机器人在特定日期自动发送消息? - discord.py How to make bot automatically send message on a specific day? 如何使 discord.py 机器人通过控制台向特定通道发送消息 - How to make a discord.py bot send a message through the console to a specific channel 如果命令处于冷却状态,如何使 discord.py 机器人发送特定消息 - how to make discord.py bot to send a specific message if the command is on cooldown 如何让我的 discord.py 机器人向我选择的频道发送我选择的消息? - how can i make my discord.py bot send a message i choose to a channel i choose? 我如何让 discord 机器人使用 Discord.py 创建和分配角色? - How do i get a discord bot to make and assign roles using Discord.py?
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM