【发布时间】:2020-12-11 17:55:22
【问题描述】:
我的机器人中有以下函数来创建 x 个空的新角色(在本例中,我将使用机器人所做的一切):
import discord
from discord.ext import commands
CLIENT = commands.Bot(command_prefix='$')
@CLIENT.event
async def on_ready():
"""triggers when bot is running"""
print("Bot online")
@CLIENT.command(pass_context=True)
async def role(ctx, x=1):
"""creates x roles"""
guild = ctx.guild
for i in range(x):
await guild.create_role(name="new role")
print("created " + str(x) + " roles")
CLIENT.run("token")
机器人不会创建新角色或打印出消息。 (根本没有输出到控制台,就好像函数刚刚说通过)我做错了什么?
【问题讨论】:
-
这可能与this question重复
-
这能回答你的问题吗? How to add and create roles in discord.py?
-
您的代码应该可以工作,除非您一遍又一遍地尝试扮演相同的角色。尝试使规则独一无二,可能使用日期和时间以及用户作者。
标签: python bots discord.py discord.py-rewrite