D
D
Demon Girl2021-08-06 19:04:22
Python
Demon Girl, 2021-08-06 19:04:22

How to write code so that after buying a personal role / room, the bot would give everything automatically?

I wrote a bot, but there are a couple of problems. The bot has a q.buy command that allows you to buy a role or a private room with a role that gives access to it. What is the best way to prescribe the automatic issuance of rooms after the purchase (+ commands for issuing the same role to other participants and changing the name of the room itself), as well as changing the name / color of the role (by commands)?
PS I'm new

mainshop = [{"name":"Личная комната","price":2500,"description":"получение комнаты и роли"},
            {"name":"Свадьба","price":1000,"description":"получение роли"},
            {"name":"Личная роль","price":4000,"description":"Возможность получить роль выделяющую тебя среди остальных"}]
###########
@client.command("buy")
async def shop(ctx):
    em = discord.Embed(title = "Магазин")

    for item in mainshop:
        name = item["name"]
        price = item["price"]
        desc = item["description"]
        em.add_field(name = name, value = f"${price} | {desc}")

    await ctx.send(embed = em)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
x4zx, 2021-08-07
@Qmensit

It doesn’t matter if you are a beginner or a pro, if there is a need, you need to read the documentation, and knowledge of the language in which you write the bot is also important.
I can only help with part of the code:

@client.command()
async def addrole(ctx, *, member: discord.Member = None):
    guild = bot.get_guild(ctx.guild.id)
    role1 = guild.get_role(ID роли которую хотите выдавать)
    if member is None:
            await ctx.reply('Укажите пользователя, которому хотите выдать роль.')
        else:
            await member.add_roles(role1)
            await ctx.reply(f'Вы успешно выдали роль...')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question