More dead code pruning (commands)

This commit is contained in:
Lamp 2018-08-26 02:18:51 -04:00
parent 368023b994
commit 9270a91b3f
17 changed files with 0 additions and 470 deletions

@ -40,21 +40,6 @@ commands.help = {
};
/*
fs.readdir('commands', (err, fileNames) => {
fileNames.forEach(fileName => {
if (fileName.startsWith('~') || !fileName.endsWith('js')) return;
fs.readFile('commands/'+fileName, 'utf8', (err, data) => {
if (err) return console.error(colors.red(err));
try {eval(data)} catch(e) {console.error(`Invalid command ${fileName}: ${e}`.red)}
});
});
});*/
client.on("message", function(message){
if (!message.content.startsWith("!")) return;

@ -1,100 +0,0 @@
commands.bots = {
restrictedTo: 1,
execute: function (message, args, txt) {
const botTokens = config.botTokens;
/*if (args[1] == 'spawn') {
const spawnBot = function (token, id) {
var client = new Discord.Client();
client.login(token);
var connection, dispatcher;
client.on('message', message => {
setTimeout(function (){
var arg = message.content.split(' ');
var cmd = arg[0].slice(1).toLowerCase();
var txt = function(i){return arg.slice(i).join(' ');};
if (message.guild && message.author.id === op && cmd == 'bots') {
if (arg[1] == id || arg[1] == 'all') {
if (arg[2] == 'ping') message.channel.send('pong');
if (arg[2] == 'eval') {
try {message.channel.send('`'+eval(txt(3).split('$id').join(id))+'`');}
catch (error) {message.channel.send('`'+error+'`');}
}
if (arg[2] == 'join') {
message.member.voiceChannel.join().then(c => {connection = c});
message.react('🆗');
}
if (arg[2] == 'play') {
message.member.voiceChannel.join().then(connection => {
dispatcher = connection.playFile(txt(3));
});
}
if (arg[2] == 'destroy') {
message.react('🆗');
client.destroy();
}
}
}
},id+0);
});
botClients[id] = client;
}
function spawnBot(token, id) {
const client = new Discord.Client();
client.login(token);
botClients[id] = client;
}
if (args[2] === 'all') {
botTokens.forEach(spawnBot);
message.react('🆗');
} else if (args[2]) {
if (args[2] > botTokens.length) return message.react('⚠');
let i;
for (i = 0; i < args[2]; i++) {
spawnBot(botTokens[i], i);
}
message.react('🆗');
} else {
message.react('⚠');
}
}*/
const q = args[1] === "all" ? botTokens.length : args[1];
if (q > botTokens.length) return message.react('⚠');
let i;
for (i = 0; i < q; i++) {
if (args[2] === "spawn") {
const client = new Discord.Client();
client.login(botTokens[i]);
botClients.push(client);
message.react('🆗');
}
(function(){
const client = botClients[i];
if (!client) return;
if (args[2] === "ping") {
client.channels.get(message.channel.id).send('pong');
}
if (args[2] === "join") {
client.channels.get(message.member.voiceChannel.id).join();
}
if (args[2] === "play") {
client.channels.get(message.member.voiceChannel.id).join().then(connection => {
connection.playFile(txt(3));
});
}
if (args[2] === "eval") {
try {var evaluation = eval(txt(3).replace(/%id/g, i))}
catch(e) {var evaluation = e}
client.channels.get(message.channel.id).send('`'+evaluation+'`');
}
if (args[2] === "destroy") {
client.destroy();
}
})();
}
}
}

@ -1,7 +0,0 @@
commands.clear = {
aliases: ["flush", "blank", "kruncherthingy"],
description: "Flushes the chat with a tall message of blankness",
execute: function (message) {
message.channel.send(`\u2063${'\n'.repeat(1998)}\u2063`);
}
}

@ -1,36 +0,0 @@
commands.color = {
aliases: ["col"],
usage: "[member] <color>",
description:
`Changes your color, the color of your personal role. You may input a hex color code or HTML color name. Invalid colors will make you colorless.
Examples:
\`!color\` tells you your color.
\`!color red\` makes you red.
\`!color <@281134216115257344>\` tells the color of the selected person.
Moderators can change others' color like so: \`!color <@281134216115257344> red\``,
execute: function (message, args, txt) {
function changeColor(message, member, colorInput) {
const colorRole = findColorRole(member);
if (!colorRole) return message.react('⚠');
colorInput = require('convert-css-color-name-to-hex')(colorInput);
colorRole.setColor(colorInput.toUpperCase()).then(() => message.react('🆗'), () => message.react('⚠'));
}
function getColor(member) {
return new Color(member.displayHexColor).getName().replace('A shade', 'a shade');
}
if (args[1]) {
//const selectedMember = (args[1].startsWith('<@') && args[1].endsWith('>') && args[1].length === 21) ? myguild.members.get(args[1].substr(2,18)) : undefined;
const selectedMember = message.mentions.members.first();
if (selectedMember) {
if (args[2]) {
if (hasPermission(message.member, 2)) changeColor(message, selectedMember, txt(2));
else message.react('🚫');
} else message.reply(`**${selectedMember.displayName}**'s color is **${getColor(selectedMember)}**.`);
} else changeColor(message, message.member, txt(1));
} else message.reply(`Your color is **${getColor(message.member)}**.`);
}
}

@ -1,10 +0,0 @@
commands.createcard = {
usage: "<title> <content>",
description: 'Creates a canned response called a "card" (or whatever you want to call it cause i\'m not sure) which you can call using the `?` prefix. For example, `!createcard foo bar` makes a card titld "foo", so when you say `?foo`, the bot says `bar`.',
execute: function (message, args, txt) {
if (!args[1] || cards[args[1]]) return message.react('⚠');
cards[args[1]] = txt(2);
fs.writeFile('cards.json', JSON.stringify(cards));
message.react('🆗');
}
}

@ -1,12 +0,0 @@
commands.eval = {
aliases: [">"],
restrictedTo: 0,
execute: function (message, args, txt) {
try {
supersend('`'+eval(message.content.substr(args[0].length))+'`', message.channel);
}
catch (error) {
supersend('`'+error+'`', message.channel);
}
}
}

@ -1,10 +0,0 @@
commands.exec = {
aliases: ["$"],
restrictedTo: 0,
execute: function (message, args, txt) {
child_process.exec(txt(1), function (error, stdout, stderr) {
if (stdout) supersend('**stdout:** ' + stdout, message.channel);
if (stderr) supersend('**stderr:** ' + stderr, message.channel);
});
}
}

@ -1,119 +0,0 @@
commands.help = {
aliases: ["robot", "commands"],
usage: "[command name]",
description: "Shows command list or details on a command.",
execute: function (message, args, txt) {
/*message.react('📨');message.react('👌');
message.author.send({embed:{
author: {name: 'Terrium Bot Commands', icon_url: client.users.get('329096040642904064').avatarURL},
color: 255,
fields: [
{name: '!help', value: 'See the commands'},
{name: '!get <id>', value: 'Quotes the message with the given ID.'},
{name: '!pin <id>', value: 'Pins the message with the given ID.'},
{name: '!createcmd <cmd> <content>', value: 'Creates a command that can be called with `?cmd` to get the `content`.'},
{name: '!report <user> <message>', value: 'Sends a `message` to the staff about the specified `user`.'},
{name: '!feature-request <message>', value: 'Submit a feature request/idea for the bot(s)!'}
]
}});
message.author.send({embed:{
author: {name: 'Music Commands', icon_url: client.users.get('338197950859575308').avatarURL},
color: 16744192,
fields: [
{name: '!play <query>', value: "Plays something... If there's no arguments, a random audio or MIDI will be played. If the input matches a MIDI or audio filename, that will be played; if not, it'll search it and pick a random result."},
{name: '!playaudio/!playmidi <query>', value: " Like play, but restricted to audio and MIDI, respectively. If no args are given, a random file is picked. If the inputted filename doesn't exist, it is searched and a random result is played."},
{name: '!search <query>', value: 'Searches the Audio and MIDI collections. All files that include the query are returned.'},
{name: '!upload', value: 'Adds the attached file to the Audio, MIDI, or soundfont collection.'},
{name: '!ytplay <query>', value: 'Plays something from YouTube.'},
{name: '!ytdl <query>', value: 'Adds music from YouTube to the audio collection.'},
{name: '!leave', value: 'Disconnects the bot from voice'},
{name: '!song, !pause, !resume, !volume, !time, and !stop', value: 'These commands control a playing song.'}
]
}});
message.author.send({embed:{
author: {name: 'Fishing Commands', icon_url: client.users.get('339146231911546882').avatarURL},
color: 3329330,
description: "F̲i̲s̲h̲i̲n̲g̲: !fish, !cast (starts fishing), !reel (stops fishing), !caught [name] (shows fish you've caught), !eat (eats one of your fish), !give [name] (gives fish to someone else), !give_[number] [name] (give up to 100 at a time), !pick (picks fruit from the tree)"
}});
message.author.send({embed:{
author: {name: 'Mee6 Commands', icon_url: client.users.get('159985870458322944').avatarURL},
color: 35255,
description: "**Custom Commands**\n **!test** \n**Levels**\n **!rank** Get a player info and rank\n **!levels** Get a link to the server leaderboard\n**Moderator**\n **!mute** \n **!clear_num** \n **!clear_user** \n **!unmute** \n **!slowmode** \n **!slowoff** \n**Search**\n **!urban dank_word** \n **!manga manga_name** \n **!imgur some_dank_search_value** \n **!pokemon pokemon_name** \n **!twitch streamer_name** \n **!youtube video_name**"
}});
message.author.send('**The command list was last updated on 7/27/17.**');
*/
/*const embed = {
author: {name: 'Terrium Bot Commands', icon_url: client.user.avatarURL},
color: message.guild.me.colorRole.color,
fields: []
}
for (const commandName in commands) {
const command = commands[commandName];
if (command.hidden) continue;
const field = {
name: `!${commandName} ${command.arguments || ""}`,
value: command.description || "\u2063",
inline: true
}
embed.fields.push(field);
}
//message[args[1] === "--here" ? "channel" : "author"].send({embed});
message.channel.send({embed});*/
if (args[1]) {
const commandName = args[1];
const command = commands[commandName];
if (!command) return message.react('❓');
const str =
'`!' + (commandName + ' ' + (command.usage || '')).trim() + '`\n'
+ (command.hasOwnProperty('aliases') ? `**Aliases:** \`${command.aliases.join(', ')}\`` : '')
+ '\n\n'
+ (command.description || '(no description)');
message.channel.send(str);
} else {
/*const embed = {
author: {name: 'About Terrium Bot', icon_url: client.user.avatarURL},
color: message.guild.me.colorRole.color,
description: `The Terrium Discord Bot is the official bot of the Terrium Community Discord Server.
Below are the available commands. Use \`!help <command>\` for more information on a command, for example, \`!help color\`.
Commands can be used in a direct message.`,
fields: []
}
const commandArray = [];
const modCommandArray = [];
for (const commandName in commands) {
const command = commands[commandName];
if (command.hidden) continue;
if (!command.hasOwnProperty('restrictedTo')) commandArray.push(`!${commandName}`);
else if (command.restrictedTo >= 2) modCommandArray.push(`!${commandName}`);
}
if (commandArray) embed.fields.push({name: "General Commands", value: commandArray.join(', ')});
//if (modCommandArray && hasPermission(message.member, 2)) embed.fields.push({name: "Moderator Commands", value: modCommandArray.join(', ')});
message.channel.send({embed});*/
let str =
"**About Terrium Bot**\n" +
"The Terrium Discord Bot is the official bot of the Terrium Community Discord Server.\n" +
"Below are the available commands. Use `!help <command>` for more information on a command, for example, `!help color`.\n" +
"Commands can be used in a direct message.";
const commandArray = [];
const modCommandArray = [];
for (const commandName in commands) {
const command = commands[commandName];
if (command.hidden) continue;
if (!command.hasOwnProperty('restrictedTo')) commandArray.push(`!${commandName}`);
else if (command.restrictedTo >= 2) modCommandArray.push(`!${commandName}`);
}
if (commandArray.length > 0) str += `\n\n**General Commands**\n${commandArray.join(', ')}`
if (hasPermission(message.member, 2) && modCommandArray.length > 0) str += `\n\n**Moderator Commands**\n${modCommandArray.join(', ')}`
message.channel.send(str);
}
}
}

@ -1,38 +0,0 @@
commands.mute = {
aliases: ["moot"],
usage: "<userTag> [duration] [reason]",
description: "Mutes the mentioned user for the given duration with the given reason.",
restrictedTo: 2,
execute: function (message, args, txt) {
if (!args[1]) return message.react('❓');
const victim = message.mentions.members.first();
if (!victim) return message.react('⚠');
message.delete();
const duration = +args[2];
const reason = txt(duration ? 3 : 2);
victim.removeRole(myguild.roles.get(config.roles[victim.user.bot?'robots':'humans']));
victim.addRole(myguild.roles.get(config.roles.muted));
if (duration) {
setTimeout(()=>{
victim.removeRole(myguild.roles.get(config.roles.muted));
victim.addRole(myguild.roles.get(config.roles[victim.user.bot?'robots':'humans']));
}, duration*60*1000);
}
message.channel.send(`🔇 **${message.member} muted ${victim}${duration ? ` for ${duration} minute${duration == 1 ? '' : 's'}.` : "."} ${reason ? `Reason: \`${reason}\`` : ""}**`);
}
}
commands.unmute = {
aliases: ["unmoot"],
arguments: "<userTag>",
description: "unmutes the mentioned user",
restrictedTo: 2,
execute: function (message, args, txt) {
if (!args[1]) return message.react('❓');
const victim = message.mentions.members.first();
if (!victim) return message.react('⚠');
message.delete();
victim.removeRole(myguild.roles.get(config.roles.muted));
victim.addRole(myguild.roles.get(config.roles[victim.user.bot?'robots':'humans']));
message.channel.send(`🔈 **${message.member} unmuted ${victim}.**`);
}
}

@ -1,13 +0,0 @@
commands.pin = {
usage: "<message IDs...>",
description: "Fetches the messages with the given IDs, and pins them. You can list multiple IDs. The messages must be in the same channel.",
execute: function (message, args) {
args.shift();
if (!args[0]) return message.react('⚠');
args.forEach(id => {
message.channel.fetchMessage(id).then(message => {
message.pin();
});
});
}
}

@ -1,29 +0,0 @@
commands.quote = {
aliases: ["get", "fetch"],
usage: "<message ID> [channel ID]",
description: "Fetches and displays the message with the given id. If the message is in a different channel, the channel ID must be given as well.",
execute: function (message, args, txt) {
if (!args[1]) return message.react('❓');
if (args[2]) {
var channel = client.channels.get(args[2]);
if (!channel) return message.react('⚠');
} else var channel = message.channel;
channel.messages.fetch(args[1]).then(m => {
var embed = {
author: {
name: (m.member && m.member.displayName) || m.author.username,
iconURL: m.author.avatarURL()
},
description: m.cleanContent,
timestamp: m.createdAt
}
if (channel.id !== message.channel.id) embed.footer = {text:`From channel #${channel.name}`};
if (m.member) embed.color = m.member.displayColor;
if (m.attachments.first()) {
if (m.attachments.first().width) embed.image = {url:m.attachments.first().url};
else embed.fields = [{name:'Attachment:', value:m.attachments.first().url}];
}
message.channel.send({embed});
}, () => message.react('⚠'));
}
}

@ -1,6 +0,0 @@
commands.randplex = {
description: "Gets a link to a random Plexpedia post",
execute: function (message, args, txt) {
message.channel.send("http://plexpedia.com/view-" + (Math.floor(Math.random()*15000)+106) );
}
}

@ -1,24 +0,0 @@
commands.load = {
restrictedTo: 1,
usage: "<command(s)...>/config",
execute: function (message, args, txt) {
if (args[1]) {
if (args[1] === "config") {
config = JSON.parse(fs.readFileSync('config.json','utf8'));
message.react('🆗');
} else {
args.slice(1).forEach(command => {
fs.readFile(`commands/${command}.js`, 'utf8', (err,data) => {
if (err) return message.react('⚠');
try {eval(data)} catch(e) {
console.error(`Invalid command ${command}: ${e}`.red);
message.react('⚠');
return;
}
message.react('🆗');
});
});
}
} else message.react('❓');
}
}

@ -1,5 +0,0 @@
commands.say = {
execute: function (message, args, txt) {
message.channel.send(txt(1));
}
}

@ -1,6 +0,0 @@
commands.spam = {
restrictedTo: 2,
execute: function (message, args, txt) {
for (t = 0; t < args[1]; t++) message.channel.send(txt(2));
}
}

@ -1,30 +0,0 @@
commands.title = {
aliases: ["tit"],
usage: "[string/user] [string]",
description:
"Sets your title, the name of your personal (color) role.\n"
+ "**Examples:** \n`!title Potato Master`\n`!title <@150369687228645386> Tester & QA` (sets others' titles)\n"
+ "Only Moderators can change others' titles.",
execute: function (message, args, txt) {
if (!args[1]) return message.reply(`Your title is **${findColorRole(message.member).name.slice(1,-1)}**.`);
function changeTitle(message, member, titleInput) {
const titleRole = findColorRole(member);
if (!titleRole) return message.react('⚠');
titleRole.setName('['+titleInput+']').then(() => message.react('🆗'), () => message.react('⚠'));
}
//const selectedMember = (args[1].startsWith('<@') && args[1].endsWith('>') && args[1].length === 21) ? myguild.members.get(args[1].substr(2,18)) : undefined;
const selectedMember = message.mentions.members.first();
if (selectedMember) {
if (args[2]) {
if (hasPermission(message.member, 2)) changeTitle(message, selectedMember, txt(2) === 'none' ? '' : txt(2));
else message.react('🚫');
} else {
message.reply(`**${selectedMember.displayName}**'s title is **${findColorRole(selectedMember).name.slice(1,-1)}**.`);
}
} else changeTitle(message, message.member, txt(1) === 'none' ? '' : txt(1));
}
}

@ -1,10 +0,0 @@
commands.report = {
usage: "<user> <message...>",
description: "Reports the user to staff with the given message.",
execute: function (message, args, txt) {
if (!args[1]) return message.react('⚠');
var reporthook = new Discord.WebhookClient('325389793082998794','MwcY9FewIVFWHEQkGK7moClwonD-MMM_I_c_MoL1E82_qnNF-zi4nOR1D5_7I7Jf1c9C');
reporthook.send('**Date:** '+Date()+'\n**Submitted by:** '+message.author.username+'\n**Reported user:** '+arg[1]+'\n**Content:** ```\n'+txt(2)+'\n```');
message.channel.send('Report sent.');
}
}