Answer the question
In order to leave comments, you need to log in
How to make a team that will create and issue a role?
How to make a command that will create a role with a name that will be written in the argument, a color that will also be written in the 2nd argument and issue it to the one who executed this command? Here is the code in which I tried to do something:
@bot.command()
async def createclan(ctx, arg, user: discord.User = None):
await ctx.message.delete()
with open("c:/Python/TOXBOT/database.json", "r", encoding = "utf-8") as read_file:
data = json.load(read_file)
if user is None:
user = ctx.author
clanleader = discord.utils.get(ctx.guild.roles, id = 772142471118716970)
for role_author in ctx.author.roles:
if role_author == clanleader:
embed = discord.Embed(description = "У вас уже имеется клан!")
embed.set_footer(text = f'Выполнил(а) {str(user)}', icon_url = user.avatar_url)
await ctx.send(embed = embed, delete_after = 20)
break
else:
if data[str(ctx.author.id)]["Баланс"] >= 10000:
data[str(ctx.author.id)]["Баланс"] -= 10000
author = ctx.message.author
guild = ctx.guild
await guild.create_role(user, name = f"{arg}", colour = discord.Colour(0xffffff))
data[str(ctx.author.id)]["Клан"] = arg
await ctx.author.add_roles(clanleader)
embed = discord.Embed(description = f'Вы успешно создали клан под названием **{arg}**!')
embed.set_footer(text = f'Выполнил(а) {str(user)}', icon_url = user.avatar_url)
await ctx.send(embed = embed, delete_after = 20)
else:
embed = discord.Embed(description = f'У вас недостаточно :coin:!')
embed.set_footer(text = f'Выполнил(а) {str(user)}', icon_url = user.avatar_url)
await ctx.send(embed = embed, delete_after = 20)
with open("c:/Python/TOXBOT/database.json", "w", encoding = "utf-8") as write:
json.dump(data, write)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question