Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Discord = require('discord.io');
- var log = require('winston');
- var auth = require('./auth.json');
- var fileSys = require('fs');
- //Configure logger settings
- log.remove(log.transports.Console);
- log.add(log.transports.Console, {
- colorize: true
- });
- log.level = 'debug';
- //Initialize Bot
- var bot = new Discord.Client({
- token: auth.token,
- autorun: true
- });
- //log info on startup
- bot.on('ready', function(evt) {
- log.info('Bup as fuck');
- log.info('Running V0.3.3');
- log.info(bot.username + ' - (' + bot.id + ')');
- });
- bot.on('message', function(user, userID, channelID, message, evt) {
- if(message.startsWith("+")) {
- var arguments = message.substring(1).split(' '); //Creates an array of strings after the first character
- var command = arguments[0]; //Names the first argument
- var userData = new function() {
- this.literalXPData = fileSys.readFileSync('data/data.json');
- this.XPData = JSON.parse(literalXPData);
- this.userXPData = XPData.xpArray
- this.testValidity = new function() {
- for(i = 0; i < userXpData.length; i++) {
- if(userXPData[i][0] = userID) {
- return true
- }
- }
- return false
- }
- }
- switch (command) {
- case 'bup':
- bot.sendMessage({
- to: channelID,
- message: ":b::up:"
- });
- break;
- case 'info':
- if(userData.testValidity) {
- bot.sendMessage({
- to: channelID,
- message: "You have " + userData.userXPData[i][1] + " expirience points"
- });
- } else {
- bot.sendMessage({
- to: channelID,
- message: "We got back nothing. Are you sure you've done +participate?"
- });
- }
- break;
- case 'participate':
- if(userData.testValidity) {
- bot.sendMessage({
- to: channelID,
- message: "You're already participating. Did you mean +participate quit?"
- });
- } else {
- userData.userXPData.push({userID, 0})
- fileSys.writeFileSync('data/data.json', JSON.stringify(userData.userXPData));
- bot.sendMessage({
- to: channelID,
- message: "You've been included the XP system."
- });
- }
- break;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement