Command help for a specific response for certain people and a random response from a list for all others

Hey @Ryan_N!

I’ve already covered this a few times before, for example I found this while searching for “user specific random response”:

Just replace the r array with $(urlfetch json RAW_PASTEBIN_LINK_CONTAINING_AN_ARRAY).

But I understand this doesn’t completely addresses your needs as it’s limiting a bit: only a single username can have a custom response.


If I had to fix your command according to the way you approached it, here’s how I’d write it:

$(eval u = '$(user)'; $(urlfetch json https://pastebin.com/raw/XXXXXXXX))

And inside of your Pastebin:

const randomMessages = [
  'RANDOM_MESSAGE_1',
  'RANDOM_MESSAGE_2',
  //...
  'RANDOM_MESSAGE_N'
]; 

switch (u) {
  case 'USERNAME_1':
    'USERNAME_1_MESSAGE';
    break;
  case 'USERNAME_2':
    'USERNAME_2_MESSAGE';
    break;
  //...
  case 'USERNAME_N':
    'USERNAME_N_MESSAGE';
    break;
  default:
    `Hello ${u}! ${randomMessages[Math.floor(Math.random() * randomMessages.length)]}`;
}