Added yodish.

This commit is contained in:
MrTech999 2020-03-11 20:47:06 +00:00
parent 76d6230e97
commit 5d8a81523f
11 changed files with 136 additions and 32 deletions

View file

@ -1,2 +1,10 @@
Added a yodish command (terry)
Links to avatars now lead to the original file size
Bots now get a bot badge in the userinfo command
Added dogfact and catfact command (terry)
index.js now has better logging of when things fail to load/initialize (terry)
added `dice`, rolls a 6 sided die (terry)
Help command changed, the amount of commands in each category and overall is now displayed
added `inspire` as an alias for inspirobot
ship command
added find by mention to functions

View file

@ -9,35 +9,35 @@ const client = new Discord.Client();
try {
client.config = require('./config');
} catch (err) {
console.log('Could not load config.js. \n', err);
console.log('Could not load config.js: \n', err);
process.exit();
}
try{
client.version = require('./version.json');
} catch (err) {
console.log('Could not load version.json. \n', err);
console.log('Could not load version.json: \n', err);
process.exit();
}
try{
client.logger = require('./src/modules/Logger');
} catch (err) {
console.log('Could not load Logger.js. \n', err);
console.log('Could not load Logger.js: \n', err);
process.exit();
}
try{
require("./src/modules/functions")(client);
} catch (err) {
console.log('Could not load functions.js. \n', err);
console.log('Could not load functions.js: \n', err);
process.exit();
}
try{
client.logger.setClient(client);
} catch (err) {
console.log('Logger failed to initialize. \n', err);
console.log('Logger failed to initialize: \n', err);
process.exit(1);
}
@ -45,34 +45,36 @@ if(process.env['USER'] != 'container') {
client.devmode = true;
} else {
client.devmode = false;
const dblapi = new DBL(client.config.dblkey, client);
if(client.config.dblkey.length == 0) {
const dblapi = new DBL(client.config.dblkey, client);
}
}
try{
client.commands = new Enmap();
} catch (err) {
console.log('Failed to create the commands map. \n', err);
console.log('Failed to create the commands database: \n', err);
process.exit();
}
try{
client.aliases = new Enmap();
} catch (err) {
console.log('Failed to create the aliases map. \n', err);
console.log('Failed to create the aliases database: \n', err);
process.exit();
}
try{
client.settings = new Enmap({name: 'settings'});
} catch (err) {
console.log('Failed to initialize the settings database. \n', err);
console.log('Failed to initialize the settings database: \n', err);
process.exit();
}
try{
client.blacklist = new Enmap({name: 'blacklist'});
} catch (err) {
console.log('Failed to initialize the blacklist database. \n', err);
console.log('Failed to initialize the blacklist database: \n', err);
process.exit(1);
}
@ -108,7 +110,7 @@ const init = async () => {
client.levelCache[thisLevel.name] = thisLevel.level;
};
} catch (err) {
console.log('Level cache failed to initialize. \n', err);
console.log('Level cache failed to initialize: \n', err);
process.exit();
}
@ -119,12 +121,12 @@ const init = async () => {
client.login(client.config.token);
};
} catch (err) {
console.log('Unable to login to Discord. \n', err);
console.log('Could not login to Discord: \n', err);
process.exit(1);
}
};
init();
} catch (err) {
console.log('Initialization failed. \n', err);
console.log('Initialization failed: \n', err);
process.exit(1);
}

View file

@ -1,10 +1,16 @@
const request = require("request");
exports.run = async (bot, message, args) => {
message.channel.startTyping();
try{
request({ uri: "https://catfact.ninja/facts", json: true }, (error, response, body) => {
if (error) throw new Error(error);
message.channel.send(`**Did you know?**\n ${body.data[0].fact}`);
message.channel.startTyping();
});
} catch(err) {
message.channel.send(`<:error:466995152976871434> API error: ${err}`);
message.channel.stopTyping();
};
};
exports.conf = {

View file

@ -1,10 +1,16 @@
const request = require("request");
exports.run = async (bot, message, args) => {
message.channel.startTyping();
try{
request({ uri: "https://dog-api.kinduff.com/api/facts", json: true }, (error, response, body) => {
if (error) throw new Error(error);
message.channel.stopTyping();
message.channel.send(`**Did you know?**\n ${body.facts[0]}`);
});
} catch(err) {
message.channel.send(`<:error:466995152976871434> API error: ${err}`);
message.channel.stopTyping();
};
};
exports.conf = {

View file

@ -4,6 +4,7 @@ exports.run = (client, message, args, level) => {
var ran = false;
var output = "";
var commands = 0;
var prefix;
var currentCategory;
@ -14,7 +15,7 @@ exports.run = (client, message, args, level) => {
};
if(!args[0]) {
embed.setTitle("Command list");
embed.setTitle(`Commands [${client.commands.size}]`);
embed.setDescription(`For more information on a specific command use \`${prefix}help <command>\`\nFor the full command list use \`${prefix}help all\`\n`);
const myCommands = message.guild ? client.commands.filter(
@ -37,16 +38,18 @@ exports.run = (client, message, args, level) => {
const cat = c.help.category.toProperCase();
if (currentCategory !== cat) {
if(ran == true) {
embed.addField(currentCategory + ":", output.slice(0, -6))
embed.addField(currentCategory + ` [${commands}]`, output.slice(0, -2))
output = "";
commands = 0;
}
currentCategory = cat;
ran = true
}
output += `\`${prefix}${c.help.name}\`**,** `;
output += `\`${prefix}${c.help.name}\`, `;
commands = commands + 1;
});
embed.addField(currentCategory + ":", output.slice(0, -6));
embed.addField(currentCategory + ` [${commands}]`, output.slice(0, -2));
embed.addField(
"Invite me",
@ -65,7 +68,7 @@ exports.run = (client, message, args, level) => {
};
if(args[0].toLowerCase() == "all") {
embed.setTitle("Command list");
embed.setTitle(`Commands [${client.commands.size}]`);
embed.setDescription(`For more information on a specific command use \`${prefix}help <command>\`\nFor the full command list use \`${prefix}help all\`\n`);
const myCommands = client.commands
@ -84,16 +87,18 @@ exports.run = (client, message, args, level) => {
const cat = c.help.category.toProperCase();
if (currentCategory !== cat) {
if(ran == true) {
embed.addField(currentCategory + ":", output.slice(0, -6))
embed.addField(currentCategory + ` [${commands}]`, output.slice(0, -2))
output = "";
commands = 0;
}
currentCategory = cat;
ran = true
}
output += `\`${prefix}${c.help.name}\`**,** `;
output += `\`${prefix}${c.help.name}\`, `;
commands = commands + 1;
});
embed.addField(currentCategory + ":", output.slice(0, -6));
embed.addField(currentCategory + ` [${commands}]`, output.slice(0, -2));
embed.addField(
"Invite me",

View file

@ -20,7 +20,7 @@ exports.run = async (client, message) => {
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
aliases: ["inspire"],
permLevel: "User",
requiredPerms: []
};

37
src/commands/ship.js Normal file
View file

@ -0,0 +1,37 @@
const request = require('request')
exports.run = async (client, message, args) => {
message.channel.startTyping();
var user = client.getUserFromMention(args[0])
var user2 = client.getUserFromMention(args[1])
var secondLength = Math.floor(user2.username.length / 2);
var first = user.username.substr(0, user.username.length / 2)
var second = user2.username.substr(secondLength, user2.username.length / 2)
try {
var attachment = new Discord.MessageAttachment(`https://api.alexflipnote.dev/ship?user=${user.avatarURL({format: "png"})}&user2=${user2.avatarURL({format: "png"})}`)
message.channel.send(`Your ship name is **${first+second}!**`, attachment)
message.channel.stopTyping();
} catch(err) {
message.channel.send(`<:error:466995152976871434> API error: ${err}`);
message.channel.stopTyping();
};
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: "User",
requiredPerms: []
};
exports.help = {
name: "ship",
category: "Fun",
description: "Ship two people together <3",
usage: "ship name name2"
};

View file

@ -50,13 +50,6 @@ exports.run = (client, message, args) => {
if(badges.length > 0) {
badges += "\n"
}
createdTimestamp = user.user.createdTimestamp;
var date = new Date(createdTimestamp * 1000);
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var seconds = "o" + date.getSeconds();
console.log(date)
user.roles.cache.forEach((role) => {
roles = roles + role.name + "`, `"

31
src/commands/yoda.js Normal file
View file

@ -0,0 +1,31 @@
const request = require('request')
exports.run = async (client, message, args) => {
const speech = args.join(' ');
if (!args[0]) {
return message.channel.send(`<:error:466995152976871434> Please include text for me to convert to yodish. Yes.`)
}
try {
const { text } = request({ uri: `http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`, json: true }, (error, response, body) => {
message.channel.send(JSON.parse(text).yodish)
});
} catch(err) {
message.channel.send(`<:error:466995152976871434> API error: ${err}`);
message.channel.stopTyping();
}
}
exports.conf = {
enabled: true,
guildOnly: false,
aliases: ["yoda","yodasay"],
permLevel: "User",
requiredPerms: []
};
exports.help = {
name: "yodish",
category: "Fun",
description: "Turns any text you input into yodish. Yes.",
usage: "yodish <text>"
};

View file

@ -133,6 +133,22 @@ module.exports = client => {
return a;
};
// USER OBJECT FROM MENTION
client.getUserFromMention = mention => {
if (!mention) return;
if (mention.startsWith('<@') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('!')) {
mention = mention.slice(1);
}
return client.users.cache.get(mention);
}
}
// MUSIC
client.music = {guilds: {}};

View file

@ -1,4 +1,4 @@
{
"number": "1.1.0",
"number": "1.2.0",
"changelog": "**1.1.0 CHANGELOG:**\n> • Added `~softban`, bans and unbans a user to clear messages\n> • Added `~emoji`, enlarges custom emojis\n> • Added `~inspirobot`, generates an inspirational quote\n> • `~serverinfo` has been changed to be more consistent, and also now displays boosts and if the server is partnered and stuff\n> • `~userinfo` has been changed to be more consistent, also added some stuff\n> • `~about` has been changed, added a thumbnail and removed the description\n> • `~colour` has been changed, it can now generate colours from text\n> • `~hackban` no longer has its own embed\n> • `~eval` now logs to hastebin if output is too large\n> • role names are no longer case sensitive\n> • `~echo` renamed `~say`\n> • Users with the ADMINISTRATOR permission now automatically recieve woomy admin\n> • Fixed `~flip`, `~purge`, `~bohemian_rhapsody` and `~creeper`\n> • Guild join/leave messages no longer include the guild name\n> • Some emojis have been changed\n> • Woomy now supports discord.js v12\n> • Files have been restructured\n> • Logger now logs error stack\n> • Restart now exits with code 0"
}