Improved twitter bot a bit more, replaced all indexOf checks, fixed xp message bug

This commit is contained in:
TheEssem 2019-11-23 17:23:28 -06:00
parent e1347fcf52
commit 0920c459d5
9 changed files with 52 additions and 43 deletions

View file

@ -52,7 +52,7 @@ exports.run = async (message, args) => {
];
if (args.length === 0) {
return `${message.author.mention}, you need to provide some text for the cow to say!`;
} else if (cowList.indexOf(args[0].toLowerCase()) > -1) {
} else if (cowList.includes(args[0].toLowerCase())) {
const cow = args.shift().toLowerCase();
return `\`\`\`\n${cowsay.say({
text: args.join(" "),

View file

@ -1,5 +1,5 @@
exports.run = async (message, args) => {
if (args.length === 0) return `${message.author.mention}, you need to provide what you want to spam!`;
if (message.content.indexOf("@everyone") > -1 || message.content.indexOf("@here") > -1) return "I don't know about you, but that seems like a bad idea.";
if (message.content.includes("@everyone") || message.content.includes("@here")) return "I don't know about you, but that seems like a bad idea.";
return args.join(" ").repeat(500).substring(0, 500);
};

View file

@ -10,7 +10,7 @@ exports.run = async (message, args) => {
switch (args[0].toLowerCase()) {
case "add":
if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to add!`;
if (blacklist.indexOf(args[1].toLowerCase()) > -1) return `${message.author.mention}, you can't make a tag with that name!`;
if (blacklist.includes(args[1].toLowerCase())) return `${message.author.mention}, you can't make a tag with that name!`;
if (tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag already exists!`;
await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild);
return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been added!`;

View file

@ -2,18 +2,22 @@ const fetch = require("node-fetch");
exports.run = async (message, args) => {
const url = args.length > 0 && args[0].match(/^\d+$/) ? `http://xkcd.com/${args[0]}/info.0.json` : "http://xkcd.com/info.0.json";
const request = await fetch(url);
const json = await request.json();
const embed = {
"embed": {
"title": json.safe_title,
"url": `https://xkcd.com/${json.num}`,
"color": 16711680,
"description": json.alt,
"image": {
"url": json.img
try {
const request = await fetch(url);
const json = await request.json();
const embed = {
"embed": {
"title": json.safe_title,
"url": `https://xkcd.com/${json.num}`,
"color": 16711680,
"description": json.alt,
"image": {
"url": json.img
}
}
}
};
return message.channel.createMessage(embed);
};
return message.channel.createMessage(embed);
} catch {
return `${message.author.mention}, I couldn't find that XKCD!`;
}
};