Skip to content

Instantly share code, notes, and snippets.

@bmax
Created December 16, 2017 04:50
Show Gist options
  • Save bmax/f52804c9748454cfe89bd901c5146e7e to your computer and use it in GitHub Desktop.
Save bmax/f52804c9748454cfe89bd901c5146e7e to your computer and use it in GitHub Desktop.
var Discord = require("discord.js");
var fs = require('fs');
// Initialize Discord Bot
const bot = new Discord.Client();
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
bot.on('ready', () => {
console.log('I am ready!' );
bot.channels.get('389275550767775745').guild.members.get(bot.user.id).setNickname("ShawnLovesDick");
});
bot.on('message', message => {
var sender = message.author.username;
console.log(sender);
if ( sender.toLowerCase == "plumpcats" ) {
message.reply("shut up");
}
var content = message.cleanContent;
if (content.split(' ')[0] == 'shawnsuckshugedick') {
var args = content.split(' ');
var cmd = args[1];
args = args.splice(1);
if ( args.join(' ') == 'say hi to me' ) {
message.reply("Hi");
}
switch (cmd) {
case 'add':
message.reply("Added " + args[1] + " to rotation");
fs.writeFile("./db.txt", args[1]+"\n", { flag: 'a' }, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
break;
case 'list':
var content = fs.readFileSync('./db.txt').toString().split('\n');
for(var i=0; i<content.length; i++){
if ( content[i] == "" ) {
continue;
}
message.reply(i + ": " + content[i] );
}
break;
case 'random':
var content = fs.readFileSync('./db.txt').toString().split('\n');
message.reply("we'll get a randokm thing from this: " + content[getRandomInt(0,content.length)]);
break;
case 'help':
message.reply("You need help?! Don't we all.");
message.reply("------------------ Just a friendly reminder ----------------");
message.reply(" Shawn sucks dick!!! ");
message.reply(" Commands so far are, shawnsuckshugedick add, shawnsuckshugedick list, shawnsuckshugedick random, shawnsuckshugedick help");
break;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment