Made command outputs post as replies, fixed status changing on cluster restart, extra stuff
This commit is contained in:
parent
08ecfc7d10
commit
364d8bf006
41 changed files with 212 additions and 159 deletions
|
@ -5,7 +5,7 @@ const Command = require("../../classes/command.js");
|
|||
class CowsayCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) {
|
||||
return `${this.message.author.mention}, you need to provide some text for the cow to say!`;
|
||||
return "You need to provide some text for the cow to say!";
|
||||
} else if (cows[this.args[0].toLowerCase()] != undefined) {
|
||||
const cow = cows[this.args.shift().toLowerCase()];
|
||||
return `\`\`\`\n${cowsay.say(this.args.join(" "), { cow })}\n\`\`\``;
|
||||
|
|
|
@ -2,7 +2,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class FullwidthCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to convert to fullwidth!`;
|
||||
if (this.args.length === 0) return "You need to provide some text to convert to fullwidth!";
|
||||
return this.args.join("").replaceAll(/[A-Za-z0-9]/g, (s) => { return String.fromCharCode(s.charCodeAt(0) + 0xFEE0); });
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class MCCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate a Minecraft achievement!`;
|
||||
if (this.args.length === 0) return "You need to provide some text to generate a Minecraft achievement!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const request = await fetch(`https://www.minecraftskinstealer.com/achievement/a.php?i=13&h=Achievement+get%21&t=${encodeURIComponent(this.args.join("+"))}`);
|
||||
return {
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
const magick = require("../../utils/image.js");
|
||||
const wrap = require("../../utils/wrap.js");
|
||||
const Command = require("../../classes/command.js");
|
||||
const ImageCommand = require("../../classes/imageCommand.js");
|
||||
|
||||
class RetroCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate some retro text!`;
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
let [line1, line2, line3] = this.args.join(" ").replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%").split(",").map(elem => elem.trim());
|
||||
class RetroCommand extends ImageCommand {
|
||||
params(args) {
|
||||
let [line1, line2, line3] = args.join(" ").replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%").split(",").map(elem => elem.trim());
|
||||
if (!line2 && line1.length > 15) {
|
||||
const [split1, split2, split3] = wrap(line1, { width: 15, indent: "" }).split("\n");
|
||||
line1 = split1;
|
||||
|
@ -20,20 +17,16 @@ class RetroCommand extends Command {
|
|||
line3 = "";
|
||||
}
|
||||
}
|
||||
const { buffer } = await magick.run({
|
||||
cmd: "retro",
|
||||
line1,
|
||||
line2,
|
||||
line3
|
||||
});
|
||||
return {
|
||||
file: buffer,
|
||||
name: "retro.png"
|
||||
};
|
||||
return { line1, line2, line3 };
|
||||
}
|
||||
|
||||
static description = "Generates a retro text image (separate lines with a comma)";
|
||||
static arguments = ["[text]", "{middle text}", "{bottom text}"];
|
||||
static arguments = ["[top text]", "{middle text}", "{bottom text}"];
|
||||
|
||||
static requiresImage = false;
|
||||
static requiresText = true;
|
||||
static noText = "You need to provide some text to make retro!";
|
||||
static command = "retro";
|
||||
}
|
||||
|
||||
module.exports = RetroCommand;
|
|
@ -3,22 +3,22 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class RPSCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0 || (this.args[0] !== "rock" && this.args[0] !== "paper" && this.args[0] !== "scissors")) return `${this.message.author.mention}, you need to choose whether you want to be rock, paper, or scissors!`;
|
||||
if (this.args.length === 0 || (this.args[0] !== "rock" && this.args[0] !== "paper" && this.args[0] !== "scissors")) return "You need to choose whether you want to be rock, paper, or scissors!";
|
||||
let emoji;
|
||||
let winOrLose;
|
||||
const result = misc.random(["rock", "paper", "scissors"]);
|
||||
switch (result) {
|
||||
case "rock":
|
||||
emoji = "✊";
|
||||
if (this.args[0].toLowerCase() === "paper") winOrLose = 1;
|
||||
if (this.args[0].toLowerCase() === "paper") winOrLose = true;
|
||||
break;
|
||||
case "paper":
|
||||
emoji = "✋";
|
||||
if (this.args[0].toLowerCase() === "scissors") winOrLose = 1;
|
||||
if (this.args[0].toLowerCase() === "scissors") winOrLose = true;
|
||||
break;
|
||||
case "scissors":
|
||||
emoji = "✌";
|
||||
if (this.args[0].toLowerCase() === "rock") winOrLose = 1;
|
||||
if (this.args[0].toLowerCase() === "rock") winOrLose = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -20,7 +20,7 @@ class XKCDCommand extends Command {
|
|||
};
|
||||
return embed;
|
||||
} catch {
|
||||
return `${this.message.author.mention}, I couldn't get that XKCD!`;
|
||||
return "I couldn't get that XKCD!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class ChannelCommand extends Command {
|
||||
async run() {
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return `${this.message.author.mention}, you need to be an administrator to enable/disable me!`;
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide whether I should be enabled or disabled in this channel!`;
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return `${this.message.author.mention}, that's not a valid option!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to enable/disable me!";
|
||||
if (this.args.length === 0) return "You need to provide whether I should be enabled or disabled in this channel!";
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
|
||||
|
||||
const guildDB = await db.getGuild(this.message.channel.guild.id);
|
||||
|
||||
|
@ -14,28 +14,28 @@ class ChannelCommand extends Command {
|
|||
let channel;
|
||||
if (this.args[1] && this.args[1].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (guildDB.disabled.includes(id)) return `${this.message.author.mention}, I'm already disabled in this channel!`;
|
||||
if (guildDB.disabled.includes(id)) return "I'm already disabled in this channel!";
|
||||
channel = this.message.channel.guild.channels.get(id);
|
||||
} else {
|
||||
if (guildDB.disabled.includes(this.message.channel.id)) return `${this.message.author.mention}, I'm already disabled in this channel!`;
|
||||
if (guildDB.disabled.includes(this.message.channel.id)) return "I'm already disabled in this channel!";
|
||||
channel = this.message.channel;
|
||||
}
|
||||
|
||||
await db.disableChannel(channel);
|
||||
return `${this.message.author.mention}, I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
|
||||
return `I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
|
||||
} else if (this.args[0].toLowerCase() === "enable") {
|
||||
let channel;
|
||||
if (this.args[1] && this.args[1].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (!guildDB.disabled.includes(id)) return `${this.message.author.mention}, I'm not disabled in that channel!`;
|
||||
if (!guildDB.disabled.includes(id)) return "I'm not disabled in that channel!";
|
||||
channel = this.message.channel.guild.channels.get(id);
|
||||
} else {
|
||||
if (!guildDB.disabled.includes(this.message.channel.id)) return `${this.message.author.mention}, I'm not disabled in this channel!`;
|
||||
if (!guildDB.disabled.includes(this.message.channel.id)) return "I'm not disabled in this channel!";
|
||||
channel = this.message.channel;
|
||||
}
|
||||
|
||||
await db.enableChannel(channel);
|
||||
return `${this.message.author.mention}, I have been re-enabled in this channel.`;
|
||||
return "I have been re-enabled in this channel.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class CountCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return `${this.message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return `${this.message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!";
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
const counts = await database.getCounts();
|
||||
const countArray = [];
|
||||
for (const entry of Object.entries(counts)) {
|
||||
|
|
|
@ -3,8 +3,8 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class DecodeCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide a string to decode!`;
|
||||
const b64Decoded = Buffer.from(this.args.join(" "), "base64").toString("utf-8");
|
||||
if (this.args.length === 0) return "You need to provide a string to decode!";
|
||||
const b64Decoded = Buffer.from(this.args.join(" "), "base64").toString("utf8");
|
||||
return `\`\`\`\n${await clean(b64Decoded)}\`\`\``;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class EmoteCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide an emoji!`;
|
||||
if (this.args.length === 0) return "You need to provide an emoji!";
|
||||
if (this.content.split(" ")[0].match(/^<a?:.+:\d+>$/)) {
|
||||
return `https://cdn.discordapp.com/emojis/${this.content.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$2")}.${this.content.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$1") === "a" ? "gif" : "png"}`;
|
||||
} else if (this.args[0].match(emojiRegex)) {
|
||||
|
@ -13,7 +13,7 @@ class EmoteCommand extends Command {
|
|||
}
|
||||
return `https://twemoji.maxcdn.com/v/latest/72x72/${codePoints.join("-").replace("-fe0f", "")}.png`;
|
||||
} else {
|
||||
return `${this.message.author.mention}, you need to provide a valid emoji to get an image!`;
|
||||
return "You need to provide a valid emoji to get an image!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class EncodeCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide a string to encode!`;
|
||||
const b64Encoded = Buffer.from(this.args.join(" ")).toString("base64");
|
||||
if (this.args.length === 0) return "You need to provide a string to encode!";
|
||||
const b64Encoded = Buffer.from(this.args.join(" "), "utf8").toString("base64");
|
||||
return `\`\`\`\n${b64Encoded}\`\`\``;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class EvalCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can use eval!`;
|
||||
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use eval!";
|
||||
const code = this.args.join(" ");
|
||||
try {
|
||||
const evaled = eval(code);
|
||||
|
|
|
@ -5,7 +5,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class ExecCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can use exec!`;
|
||||
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use exec!";
|
||||
const code = this.args.join(" ");
|
||||
try {
|
||||
const execed = await exec(code);
|
||||
|
|
|
@ -4,13 +4,13 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class ImageSearchCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return `${this.message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return `${this.message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide something to search for!`;
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!";
|
||||
if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
||||
const embeds = [];
|
||||
const images = await image_search({ query: this.args.join(" "), moderate: true });
|
||||
if (images.error && images.error.code === 403) return `${this.message.author.mention}, the daily search quota has been exceeded. Check back later.`;
|
||||
if (images.length === 0) return `${this.message.author.mention}, I couldn't find any results!`;
|
||||
if (images.error && images.error.code === 403) return "The daily search quota has been exceeded. Check back later.";
|
||||
if (images.length === 0) return "I couldn't find any results!";
|
||||
for (const [i, value] of images.entries()) {
|
||||
embeds.push({
|
||||
"embed": {
|
||||
|
|
|
@ -4,7 +4,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class ImageReloadCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can reload the image servers!`;
|
||||
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload the image servers!";
|
||||
await image.disconnect();
|
||||
await image.repopulate();
|
||||
let amount = 0;
|
||||
|
@ -19,7 +19,7 @@ class ImageReloadCommand extends Command {
|
|||
if (amount > 0) {
|
||||
return `Successfully connected to ${amount} image servers.`;
|
||||
} else {
|
||||
return `${this.message.author.mention}, I couldn't connect to any image servers!`;
|
||||
return "I couldn't connect to any image servers!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class InviteCommand extends Command {
|
||||
async run() {
|
||||
return `${this.message.author.mention}, you can invite me to your server here: <https://projectlounge.pw/invite>`;
|
||||
return "You can invite me to your server here: <https://projectlounge.pw/invite>";
|
||||
}
|
||||
|
||||
static description = "Gets my invite link";
|
||||
|
|
|
@ -5,12 +5,12 @@ const Command = require("../../classes/command.js");
|
|||
class LengthenCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
if (this.args.length === 0 || !urlCheck(this.args[0])) return `${this.message.author.mention}, you need to provide a short URL to lengthen!`;
|
||||
if (this.args.length === 0 || !urlCheck(this.args[0])) return "You need to provide a short URL to lengthen!";
|
||||
if (urlCheck(this.args[0])) {
|
||||
const url = await fetch(encodeURI(this.args[0]), { redirect: "manual" });
|
||||
return url.headers.get("location") || this.args[0];
|
||||
} else {
|
||||
return `${this.message.author.mention}, that isn't a URL!`;
|
||||
return "That isn't a URL!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class PingCommand extends Command {
|
||||
async run() {
|
||||
const pingMessage = await this.client.createMessage(this.message.channel.id, "🏓 Ping?");
|
||||
const pingMessage = await this.client.createMessage(this.message.channel.id, Object.assign({
|
||||
content: "🏓 Ping?"
|
||||
}, this.reference));
|
||||
return pingMessage.edit(`🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.message.channel.guild ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.message.channel.guild.id]).latency)}ms` : ""}\n\`\`\``);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class PrefixCommand extends Command {
|
||||
async run() {
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
const guild = await database.getGuild(this.message.channel.guild.id);
|
||||
if (this.args.length !== 0) {
|
||||
if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return `${this.message.author.mention}, you need to be an administrator to change the bot prefix!`;
|
||||
if (!this.message.member.permission.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to change the bot prefix!";
|
||||
await database.setPrefix(this.args[0], this.message.channel.guild);
|
||||
return `The prefix has been changed to ${this.args[0]}.`;
|
||||
} else {
|
||||
return `${this.message.author.mention}, the current prefix is \`${guild.prefix}\`.`;
|
||||
return `The current prefix is \`${guild.prefix}\`.`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class QrCreateCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide some text to generate a QR code!`;
|
||||
if (this.args.length === 0) return "You need to provide some text to generate a QR code!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const writable = new stream.PassThrough();
|
||||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
|
|
|
@ -7,12 +7,12 @@ const Command = require("../../classes/command.js");
|
|||
class QrReadCommand extends Command {
|
||||
async run() {
|
||||
const image = await require("../../utils/imagedetect.js")(this.client, this.message);
|
||||
if (image === undefined) return `${this.message.author.mention}, you need to provide an image with a QR code to read!`;
|
||||
if (image === undefined) return "You need to provide an image with a QR code to read!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const data = await (await fetch(image.path)).buffer();
|
||||
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
if (!qrBuffer) return `${this.message.author.mention}, I couldn't find a QR code!`;
|
||||
if (!qrBuffer) return "I couldn't find a QR code!";
|
||||
return `\`\`\`\n${await clean(qrBuffer.data)}\n\`\`\``;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ class ReloadCommand extends Command {
|
|||
// quite possibly one of the hackiest commands in the bot
|
||||
run() {
|
||||
return new Promise((resolve) => {
|
||||
if (this.message.author.id !== process.env.OWNER) resolve(`${this.message.author.mention}, only the bot owner can reload commands!`);
|
||||
if (this.args.length === 0) resolve(`${this.message.author.mention}, you need to provide a command to reload!`);
|
||||
if (this.message.author.id !== process.env.OWNER) resolve("Only the bot owner can reload commands!");
|
||||
if (this.args.length === 0) resolve("You need to provide a command to reload!");
|
||||
this.ipc.broadcast("reload", { cmd: this.args[0] });
|
||||
this.ipc.register("reloadSuccess", () => {
|
||||
this.ipc.unregister("reloadSuccess");
|
||||
this.ipc.unregister("reloadFail");
|
||||
resolve(`${this.message.author.mention}, the command \`${this.args[0]}\` has been reloaded.`);
|
||||
resolve(`The command \`${this.args[0]}\` has been reloaded.`);
|
||||
});
|
||||
this.ipc.register("reloadFail", (message) => {
|
||||
this.ipc.unregister("reloadSuccess");
|
||||
|
|
|
@ -4,8 +4,10 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class RestartCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can restart me!`;
|
||||
await this.client.createMessage(this.message.channel.id, `${this.message.author.mention}, esmBot is restarting.`);
|
||||
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can restart me!";
|
||||
await this.client.createMessage(this.message.channel.id, Object.assign({
|
||||
content: "esmBot is restarting."
|
||||
}, this.reference));
|
||||
for (const command of collections.commands) {
|
||||
await handler.unload(command);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class ServerInfoCommand extends Command {
|
||||
async run() {
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
const owner = await this.message.channel.guild.members.get(this.message.channel.guild.ownerID);
|
||||
return {
|
||||
"embed": {
|
||||
|
|
|
@ -2,8 +2,8 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class SnowflakeCommand extends Command {
|
||||
async run() {
|
||||
if (!this.args[0]) return `${this.message.author.mention}, you need to provide a snowflake ID!`;
|
||||
if (!this.args[0].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[0] < 21154535154122752) return `${this.message.author.mention}, that's not a valid snowflake!`;
|
||||
if (!this.args[0]) return "You need to provide a snowflake ID!";
|
||||
if (!this.args[0].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[0] < 21154535154122752) return "That's not a valid snowflake!";
|
||||
return new Date((this.args[0].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "") / 4194304) + 1420070400000).toUTCString();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class SoundReloadCommand extends Command {
|
||||
async run() {
|
||||
if (this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, only the bot owner can reload Lavalink!`;
|
||||
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload Lavalink!";
|
||||
const soundStatus = await soundPlayer.checkStatus();
|
||||
if (!soundStatus) {
|
||||
const length = await soundPlayer.connect(this.client);
|
||||
return `Successfully connected to ${length} Lavalink node(s).`;
|
||||
} else {
|
||||
return `${this.message.author.mention}, I couldn't connect to any Lavalink nodes!`;
|
||||
return "I couldn't connect to any Lavalink nodes!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ const Command = require("../../classes/command.js");
|
|||
|
||||
class YouTubeCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to provide something to search for!`;
|
||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
const messages = [];
|
||||
const request = await fetch(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(this.args.join(" "))}&key=${process.env.GOOGLE}&maxResults=50`);
|
||||
const result = await request.json();
|
||||
if (result.error && result.error.code === 403) return `${this.message.author.mention}, I've exceeded my YouTube API search quota for the day. Check back later.`;
|
||||
if (result.error && result.error.code === 403) return "I've exceeded my YouTube API search quota for the day. Check back later.";
|
||||
for (const [i, value] of result.items.entries()) {
|
||||
if (value.id.kind === "youtube#channel") {
|
||||
messages.push(`Page ${i + 1} of ${result.items.length}\n<:youtube:637020823005167626> **${decodeEntities(value.snippet.title).replaceAll("*", "\\*")}**\nhttps://youtube.com/channel/${value.id.channelId}`);
|
||||
|
|
|
@ -5,10 +5,10 @@ class LoopCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (this.connection.host !== this.message.author.id) return `${this.message.author.mention}, only the current voice session host can loop the music!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can loop the music!";
|
||||
const object = this.connection;
|
||||
object.loop = !object.loop;
|
||||
soundPlayer.players.set(this.message.channel.guild.id, object);
|
||||
|
|
|
@ -8,11 +8,11 @@ class NowPlayingCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
const player = this.connection.player;
|
||||
if (!player) return `${this.message.author.mention}, I'm not playing anything!`;
|
||||
if (!player) return "I'm not playing anything!";
|
||||
const track = await fetch(`http://${player.node.host}:${player.node.port}/decodetrack?track=${encodeURIComponent(player.track)}`, { headers: { Authorization: player.node.password } }).then(res => res.json());
|
||||
const parts = Math.floor((player.state.position / track.length) * 10);
|
||||
return {
|
||||
|
|
|
@ -4,10 +4,10 @@ class PauseCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (this.connection.host !== this.message.author.id) return `${this.message.author.mention}, only the current voice session host can pause/resume the music!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can pause/resume the music!";
|
||||
const player = this.connection.player;
|
||||
player.pause(!player.paused ? true : false);
|
||||
return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`;
|
||||
|
|
|
@ -7,7 +7,7 @@ class PlayCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.args[0]) return `${this.message.author.mention}, you need to provide what you want to play!`;
|
||||
if (!this.args[0]) return "You need to provide what you want to play!";
|
||||
const query = this.args.join(" ").trim();
|
||||
const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
|
||||
return await soundPlayer.play(this.client, encodeURIComponent(search), this.message, true);
|
||||
|
|
|
@ -10,11 +10,11 @@ class QueueCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return `${this.message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return `${this.message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!";
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
const queue = soundPlayer.queues.get(this.message.channel.guild.id);
|
||||
const player = this.connection;
|
||||
const tracks = await fetch(`http://${player.player.node.host}:${player.player.node.port}/decodetracks`, { method: "POST", body: JSON.stringify(queue), headers: { Authorization: player.player.node.password, "Content-Type": "application/json" } }).then(res => res.json());
|
||||
|
@ -53,7 +53,7 @@ class QueueCommand extends MusicCommand {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (embeds.length === 0) return `${this.message.author.mention}, there's nothing in the queue!`;
|
||||
if (embeds.length === 0) return "There's nothing in the queue!";
|
||||
return paginator(this.client, this.message, embeds);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ class SkipCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
const player = this.connection;
|
||||
if (player.host !== this.message.author.id) {
|
||||
const votes = soundPlayer.skipVotes.has(this.message.channel.guild.id) ? soundPlayer.skipVotes.get(this.message.channel.guild.id) : { count: 0, ids: [] };
|
||||
if (votes.ids.includes(this.message.author.id)) return `${this.message.author.mention}, you've already voted to skip!`;
|
||||
if (votes.ids.includes(this.message.author.id)) return "You've already voted to skip!";
|
||||
const newObject = {
|
||||
count: votes.count + 1,
|
||||
ids: [...votes.ids, this.message.author.id].filter(item => !!item)
|
||||
|
|
|
@ -5,10 +5,10 @@ class StopCommand extends MusicCommand {
|
|||
async run() {
|
||||
if (process.env.NODE_ENV === "production") return "Music commands are coming soon, but they aren't ready yet. Stay tuned to @esmBot_ on Twitter for updates!";
|
||||
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.member.voiceState.channelID) return `${this.message.author.mention}, you need to be in a voice channel first!`;
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return `${this.message.author.mention}, I'm not in a voice channel!`;
|
||||
if (this.connection.host !== this.message.author.id) return `${this.message.author.mention}, only the current voice session host can stop the music!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
|
||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can stop the music!";
|
||||
soundPlayer.manager.leave(this.message.channel.guild.id);
|
||||
const connection = this.connection.player;
|
||||
connection.destroy();
|
||||
|
|
|
@ -6,42 +6,42 @@ const Command = require("../../classes/command.js");
|
|||
class TagsCommand extends Command {
|
||||
// todo: find a way to split this into subcommands
|
||||
async run() {
|
||||
if (!this.message.channel.guild) return `${this.message.author.mention}, this command only works in servers!`;
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
const guild = await database.getGuild(this.message.channel.guild.id);
|
||||
|
||||
if ((guild.tagsDisabled || guild.tags_disabled) && this.args[0].toLowerCase() !== ("enable" || "disable")) return;
|
||||
if (this.args.length === 0) return `${this.message.author.mention}, you need to specify the name of the tag you want to view!`;
|
||||
if (this.args.length === 0) return "You need to provide the name of the tag you want to view!";
|
||||
const tags = guild.tags instanceof Map ? Object.fromEntries(guild.tags) : guild.tags;
|
||||
const blacklist = ["add", "edit", "remove", "delete", "list", "random", "own", "owner", "enable", "disable"];
|
||||
switch (this.args[0].toLowerCase()) {
|
||||
case "add":
|
||||
if (this.args[1] === undefined) return `${this.message.author.mention}, you need to provide the name of the tag you want to add!`;
|
||||
if (blacklist.includes(this.args[1].toLowerCase())) return `${this.message.author.mention}, you can't make a tag with that name!`;
|
||||
if (tags[this.args[1].toLowerCase()]) return `${this.message.author.mention}, this tag already exists!`;
|
||||
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to add!";
|
||||
if (blacklist.includes(this.args[1].toLowerCase())) return "You can't make a tag with that name!";
|
||||
if (tags[this.args[1].toLowerCase()]) return "This tag already exists!";
|
||||
var result = await this.setTag(this.args.slice(2).join(" "), this.args[1].toLowerCase(), this.message, guild);
|
||||
if (result) return result;
|
||||
return `${this.message.author.mention}, the tag \`${this.args[1].toLowerCase()}\` has been added!`;
|
||||
return `The tag \`${this.args[1].toLowerCase()}\` has been added!`;
|
||||
case "delete":
|
||||
case "remove":
|
||||
if (this.args[1] === undefined) return `${this.message.author.mention}, you need to provide the name of the tag you want to delete!`;
|
||||
if (!tags[this.args[1].toLowerCase()]) return `${this.message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, you don't own this tag!`;
|
||||
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to delete!";
|
||||
if (!tags[this.args[1].toLowerCase()]) return "This tag doesn't exist!";
|
||||
if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!";
|
||||
await database.removeTag(this.args[1].toLowerCase(), this.message.channel.guild);
|
||||
return `${this.message.author.mention}, the tag \`${this.args[1].toLowerCase()}\` has been deleted!`;
|
||||
return `The tag \`${this.args[1].toLowerCase()}\` has been deleted!`;
|
||||
case "edit":
|
||||
if (this.args[1] === undefined) return `${this.message.author.mention}, you need to provide the name of the tag you want to edit!`;
|
||||
if (!tags[this.args[1].toLowerCase()]) return `${this.message.author.mention}, this tag doesn't exist!`;
|
||||
if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, you don't own this tag!`;
|
||||
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to edit!";
|
||||
if (!tags[this.args[1].toLowerCase()]) return "This tag doesn't exist!";
|
||||
if (tags[this.args[1].toLowerCase()].author !== this.message.author.id && !this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!";
|
||||
await this.setTag(this.args.slice(2).join(" "), this.args[1].toLowerCase(), this.message, guild);
|
||||
return `${this.message.author.mention}, the tag \`${this.args[1].toLowerCase()}\` has been edited!`;
|
||||
return `The tag \`${this.args[1].toLowerCase()}\` has been edited!`;
|
||||
case "own":
|
||||
case "owner":
|
||||
if (this.args[1] === undefined) return `${this.message.author.mention}, you need to provide the name of the tag you want to check the owner of!`;
|
||||
if (!tags[this.args[1].toLowerCase()]) return `${this.message.author.mention}, this tag doesn't exist!`;
|
||||
return `${this.message.author.mention}, this tag is owned by **${this.client.users.get(tags[this.args[1].toLowerCase()].author).username}#${this.client.users.get(tags[this.args[1].toLowerCase()].author).discriminator}** (\`${tags[this.args[1].toLowerCase()].author}\`).`;
|
||||
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to check the owner of!";
|
||||
if (!tags[this.args[1].toLowerCase()]) return "This tag doesn't exist!";
|
||||
return `This tag is owned by **${this.client.users.get(tags[this.args[1].toLowerCase()].author).username}#${this.client.users.get(tags[this.args[1].toLowerCase()].author).discriminator}** (\`${tags[this.args[1].toLowerCase()].author}\`).`;
|
||||
case "list":
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return `${this.message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return `${this.message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("addReactions")) return "I don't have the `Add Reactions` permission!";
|
||||
if (!this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
var pageSize = 15;
|
||||
var embeds = [];
|
||||
var groups = Object.keys(tags).map((item, index) => {
|
||||
|
@ -66,23 +66,23 @@ class TagsCommand extends Command {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (embeds.length === 0) return `${this.message.author.mention}, I couldn't find any tags!`;
|
||||
if (embeds.length === 0) return "I couldn't find any tags!";
|
||||
return paginator(this.client, this.message, embeds);
|
||||
case "random":
|
||||
return tags[random(Object.keys(tags))].content;
|
||||
case "enable":
|
||||
case "disable":
|
||||
if (!this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return `${this.message.author.mention}, you don't have permission to disable tags!`;
|
||||
if (!this.message.member.permission.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't have permission to disable tags!";
|
||||
var toggleResult = await database.toggleTags(this.message.channel.guild);
|
||||
return `${this.message.author.mention}, tags for this guild have been ${toggleResult ? "disabled" : "enabled"}. To ${toggleResult ? "enable" : "disable"} them again, run ${guild.prefix}tags ${toggleResult ? "enable" : "disable"}.`;
|
||||
return `Tags for this guild have been ${toggleResult ? "disabled" : "enabled"}. To ${toggleResult ? "enable" : "disable"} them again, run ${guild.prefix}tags ${toggleResult ? "enable" : "disable"}.`;
|
||||
default:
|
||||
if (!tags[this.args[0].toLowerCase()]) return `${this.message.author.mention}, this tag doesn't exist!`;
|
||||
if (!tags[this.args[0].toLowerCase()]) return "This tag doesn't exist!";
|
||||
return tags[this.args[0].toLowerCase()].content;
|
||||
}
|
||||
}
|
||||
|
||||
async setTag(content, name, message) {
|
||||
if ((!content || content.length === 0) && message.attachments.length === 0) return `${message.author.mention}, you need to provide the content of the tag!`;
|
||||
if ((!content || content.length === 0) && message.attachments.length === 0) return "You need to provide the content of the tag!";
|
||||
if (message.attachments.length !== 0 && content) {
|
||||
await database.setTag(name, { content: `${content} ${message.attachments[0].url}`, author: message.author.id }, message.channel.guild);
|
||||
} else if (message.attachments.length !== 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue