Help with custom made discord bot

Hye, so I am creating a custom discord bot but when i try to use a command :- !ping staff which is a custom command, it doesnt work. can someone help me please?

Here is the repo link :- lololololomememe/custom-dylandeck-server-bot · GitHub

Hi, that repo’s empty. It would also be nice if you could say exactly in what way the commabd isn’t woeking, and what it’s meant to do.
Also moved to #discord-help

Just added the file. Please check in. Really need help!

Its suppose to mention @Staff Team when someone types !ping staff but testing if with multiple debugs didn’t work.

Ok so there are multiple issues here. Firstly, on line 14 you’re splitting the message at all spaces, and then expecting the first word to equal “ping staff”, which has a space in it, do that not going to work. Instead, you could replace the switch option with “ping”, and then have a switch statement for the next item of the message array, then see if it’s equal to “staff”, then carry out the reply. Secondly, just putting “@staff” in the message won’t ping that role. You need to find the id of the role, and replace @staff with <@&staffid>. Thirdly, you exposed your token. Hopefully discord will have automatically invalidated the token, but you should generate a new token, otherwise anyone could hack your bot.

Already regenerated it! Didn’t understand too much but will try!

Not understanding at all because M quite new to Node.js. Is it possible for you to send the working script here?

Something like this should work (replace the switch statement with this):

switch (args[0]){
        case 'ping':
            switch (args[1]) {
              case "staff":
                message.channel.send('<@&PUT_THE_ID_OF_THE_STAFF_ROLE_HERE> Someone is calling for help! Please investigate and resolve it quickly!');
               break;
      }
      break;
    }

You’ll have to do a bit of research on how exactly to get the id of the staff role (I’d imagine you turn on developer mode and right click it), but that should work, potentially with a couple of tweaks. But really the heart of the problem was that you were splitting the message at spaces, so if I were to send !eat a potato it would output an array of ["eat", "a", "potato"] - noyice that each item of the array is a single word. In your switch statement, you were seeing if the first item of that array was “ping staff” - which is impossible as it’s two words.

Thanks for the help! Working on the fix!

Also, should I delete the split code?

Only if you want to - it’s your code :slight_smile: it really depends if you’re ok with extra stuff after the command still triggering the command or not, and whether that will make expanding your bot more difficult for you.

M following suggested actions. Should I delete it or keep it?

1 Like

If I were you I’d keep it - it’ll help improve maintainability in the future.

Actually, harder than I think. Can you friend me on Discord. DylanHypedup#9542

Really need someone like you.

It also looks like you leaked your token, you shouldn’t have that on GitHub.

I already regenerated it

Now that I got that working, another error pops up :- https://1drv.ms/u/s!AtbyNBLH5LRwuW4NIDgfHn_sVLxP?e=nWIQ2b

Again, the token is useless… It has been regenarated

require("./commands/") doesn’t work because it’s a directory, not a file. You need to do something like require("./commands/kick.js").

Alright. Fixing it now!

Care to share the code here? Messed the code into a pile of junk and garbage!