D
D
Dream2021-06-08 19:07:46
Python
Dream, 2021-06-08 19:07:46

How to change bot config with commands in Discord?

Greetings, how can I make sure that a certain element changes in the config with a certain command? Let's say - !set-prefix s! (actually, the bot should now have an s prefix!), s!set-currency $ , etc.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Neverov, 2021-06-08
@TTATPuOT

Use a database and store all "configs" in it. On command to update the data in the database.

A
Alexey, 2021-06-08
@Azperin

you still have these settings somehow loaded, take it and change it

let prefix = '!';
let currencySymbol = '@';
discordBot.on('message', (msg) => {
  let [ command, ...args ] = msg.content.split(' ');
  
  switch(true) {
    case(command === `{ $prefix }set-prefix`):
      prefix = args[0] ?? prefix;
      break;
    
    case(command === `{ $prefix }set-currency`):
      currencySymbol = args[0] ?? currencySymbol;
      break;		
      
    default: break;
  };
  
});

I did not immediately see the python tag, but I think there are no radical differences.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question