S
S
Sergey2020-08-03 15:14:03
JavaScript
Sergey, 2020-08-03 15:14:03

How to pass a parameter to a discord bot?

I decided to implement a simple game and ran into a problem
. I have 5 chat rooms and I need to send luggage to the 3rd room, for example, with the help of the command! Baggage 3 (well, or any other room)
Here is a super simple function that gives us luggage

function Baggage() {
var ArrayBaggage = ['Абонемент в спортзал','Фотоаппарат','Мультивитамины','Шикарное свадебное платье'];
var number=randomNumber(0, ArrayBaggage.length-1);
var Finnal="Специальная карта:"+ ArrayBaggage[number];
  return Finnal;
}

It would be possible to write hundreds of if-fs that were responsible for sending luggage to the right room
client.on('message', msg => {
if (msg.content === '!Baggage3') {
    msg.reply(Baggage()); //написать в канал 3 багаж 
  }
if (msg.content === '!Baggage1') {
    msg.reply(Baggage()); //написать в канал 1 багаж 
  }
if (msg.content === '!Baggage2') {
    msg.reply(Baggage()); //написать в канал 2 багаж 
  }});

but this is bullshit because there is not only luggage but also other parameters ..
how to be???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-08-03
@Alexandre888

for loop use

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question