S
S
Shandy2021-03-02 15:09:27
Python
Shandy, 2021-03-02 15:09:27

How to change the prefix with a command?

There were already such questions on Habré, but I did not find a suitable answer. In general, I want to change the prefix by command, and take the prefix itself from the database. The problem is in the function call. More precisely, I don’t quite understand how you can take the id of the server for which you need to get the prefix.

def get_prefix(guild):
    with con:
        cur = con.cursor()
        cur.execute(f"SELECT prefix FROM simple_voice.server_{guild.id};")
        rows = cur.fetchall()

bot: commands.Bot = commands.Bot(command_prefix=get_prefix(тут нужно передавать сервер))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shandy, 2021-03-02
@MrShandy

def get_prefix(bot, message):
    with con:
        cur = con.cursor()
        cur.execute(f"SELECT prefix FROM simple_voice.server_{message.guild.id};")
        row = cur.fetchone()
        return row

bot = commands.Bot(command_prefix = get_prefix, instintents = discord.Intents.all())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question