Need help creating discord bot: removing the need of a prefix

I have been learning java recently and thought I might have the knowledge to make a simple discord bot
to build the bases of the bot i watched a tutorial to set up the application and then further on some starting code
in this tutorial they use a prefix for the bot to determine if it should respond. I was wondering how I could remove the need of a prefix any help would be great. i have seen it done on many bots so at least i know its possible
I’m using visual studio to write it and node as my core

here’s the code:

var Discord = require(‘’);

var logger = require(‘winston’);

var auth = require(’./auth.json’);

// Configure logger settings


logger.add(new logger.transports.Console, {

colorize: true


logger.level = ‘debug’;

// Initialize Discord Bot

var bot = new Discord.Client({

token: auth.token,

autorun: true


bot.on(‘ready’, function (evt) {'Connected');'Logged in as: '); + ' - (' + + ')');


bot.on(‘message’, function (user, userID, channelID, message, evt)

// Our bot needs to know if it will execute a command

// It will listen for messages that will start with `!`

{if (message.substring(0, 1) == '!') {

    var args = message.substring(1).split(' ');

    var cmd = args[0];


    args = args.splice(1);

    switch(cmd) {

        // !ping

        case 'ping':


                to: channelID,

                message: 'Pong!'



        // Just add any case commands if you want to..