我试图使一个机器人,可以创建角色,但机器人是不承认我的命令。
我试过使用OpenAI,但是它的知识有限。我只需要一个工作的方法来接收命令和创建角色。这是最大的
'
import sys
command_prefix = "!"
async def create_role(guild, role_name):
# Create the role
role = await guild.create_role(name=role_name)
return role
@client.event
async def on_message(message):
if message.content.startswith(f"{command_prefix}gr"):
# Split the message into a list of arguments
args = message.content.split(" ")
# The name of the role is the second argument
role_name = args[1]
print(f"Creating role {role_name}") # Debug statement
# Create the role
role = await create_role(message.guild, role_name)
# Give the role to the user who sent the message
await assign_role(message.author, role)
await message.channel.send(
f'Created role {role_name} and gave it to {message.author}')
client.run(
'TOKEN')
'
1条答案
按热度按时间gab6jxml1#
您应该使用命令