BTMorton BTMorton - 2 months ago
191 0

No description

Javascript

Up dated - Discord Bot

const Discord = require('discord.js');
const bot = new Discord.Client();

let url = "http://ephe.github.io/grimoire/spells/";
let d = "-";
let prefix = "!";
let prefix2 = "?"
let x = 0


bot.on('ready', () => {
  console.log('I am ready!');
});

bot.on('message', message => {
	if (message.content.startsWith(prefix)) {
		let args = message.content.slice(1).toLowerCase().split(" ").filter((s) => s);
		
		switch (args[0]) {
			case "spell":
				if (args.length > 1) {
					if (args[1] === "help") {
						message.reply("Type spell with ! followed by spell name for example !spell gust, and i'll get you the spell info")
					} else {
						let spell = url + args.slice(1).join(d);
						message.reply(spell);
					}
				} else {
					message.reply("Type spell with ! followed by spell name for example !spell gust, and i'll get you the spell info")
				}
				break;
			case "help":
				message.reply("Type spell with ! followed by spell name for example !spell gust, and i'll get you the spell info")
				break;
		}
	}
});

bot.login('');
Comments