renesansz / discord-greeter-bot

My greeter bot for Discord
MIT License
49 stars 38 forks source link

Node bot.js is not working #269

Closed CrxsTagz closed 4 years ago

CrxsTagz commented 4 years ago

I get this message

mielderia

and my code is this:

var Discord = require('discord.io'); var logger = require('winston'); var auth = require('./auth.json'); // Configure logger settings logger.remove(logger.transports.Console); logger.add(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) { logger.info('Connected'); logger.info('Logged in as: '); logger.info(bot.username + ' - (' + bot.id + ')'); }); 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) {
        // !hey
        case 'Hey':
            bot.sendMessage({
                to: channelID,
                message: 'klk mmgvs, Welcome to International Coro'
            });
        break;
        // Just add any case commands if you want to..
     }
 }

});

same as the website

sarthaktexas commented 4 years ago

send auth,json WITHOUT token

sarthaktexas commented 4 years ago

actually, replace auth.json with .env and add this to your bot.js: require('dotenv').config(); then in .env, put this DISCORD_TOKEN: blah blah and finally, token: process.env.DISCORD_TOKEN (instead of auth.token)

CrxsTagz commented 4 years ago

let me see if i get it. i replace the auth with .env which is going to be auth.env

i will put that .env in the variable auth which is going to be auth = require('dotenv').config();

and then the token would be token: process.env.DISCORD_TOKEN

sarthaktexas commented 4 years ago

sorry for the late reply. I mean replace the file auth.json with the file .env. and just put the require statement at the top. don't need to assign to a variable. and the rest is correct.

eltrevii commented 4 years ago

(Reply to ur message)

I get this message

mielderia

and my code is this:

var Discord = require('discord.io'); var logger = require('winston'); var auth = require('./auth.json'); // Configure logger settings logger.remove(logger.transports.Console); logger.add(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) { logger.info('Connected'); logger.info('Logged in as: '); logger.info(bot.username + ' - (' + bot.id + ')'); }); 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) {
        // !hey
        case 'Hey':
            bot.sendMessage({
                to: channelID,
                message: 'klk mmgvs, Welcome to International Coro'
            });
        break;
        // Just add any case commands if you want to..
     }
 }

});

same as the website

You need to see dis

image

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.