html-ified some commands, removed some others

This commit is contained in:
murm 2023-03-17 01:55:25 -04:00
parent 080e957655
commit e66945fccd
7 changed files with 4 additions and 180 deletions

View file

@ -12,10 +12,10 @@ class Base64Command extends Command {
this.success = true; this.success = true;
if (command === "decode") { if (command === "decode") {
const b64Decoded = Buffer.from(string, "base64").toString("utf8"); const b64Decoded = Buffer.from(string, "base64").toString("utf8");
return `\`\`\`\n${await clean(b64Decoded)}\`\`\``; return { html: `<pre><code>${await clean(b64Decoded)}</pre></code>` };
} else if (command === "encode") { } else if (command === "encode") {
const b64Encoded = Buffer.from(string, "utf8").toString("base64"); const b64Encoded = Buffer.from(string, "utf8").toString("base64");
return `\`\`\`\n${b64Encoded}\`\`\``; return { html: `<pre><code>${b64Encoded}</pre></code>` };
} }
} }

View file

@ -1,52 +0,0 @@
import Command from "../../classes/command.js";
import database from "../../utils/database.js";
import { endBroadcast, startBroadcast } from "../../utils/misc.js";
class BroadcastCommand extends Command {
async run() {
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author)) {
this.success = false;
return "Only the bot owner can broadcast messages!";
}
const message = this.options.message ?? this.args.join(" ");
if (message?.trim()) {
await database.setBroadcast(message);
startBroadcast(this.client, message);
if (process.env.PM2_USAGE) {
process.send({
type: "process:msg",
data: {
type: "broadcastStart",
message
}
});
}
return "Started broadcast.";
} else {
await database.setBroadcast(null);
endBroadcast(this.client);
if (process.env.PM2_USAGE) {
process.send({
type: "process:msg",
data: {
type: "broadcastEnd"
}
});
}
return "Ended broadcast.";
}
}
static flags = [{
name: "message",
type: 3,
description: "The message to broadcast"
}];
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
static adminOnly = true;
static dbRequired = true;
}
export default BroadcastCommand;

View file

@ -1,53 +0,0 @@
import db from "../../utils/database.js";
import Command from "../../classes/command.js";
class ChannelCommand extends Command {
async run() {
this.success = false;
if (!this.guild) return "This command only works in servers!";
const owners = process.env.OWNER.split(",");
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) 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.guild.id);
if (this.args[0].toLowerCase() === "disable") {
let channel;
if (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 "I'm already disabled in this channel!";
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
} else {
if (guildDB.disabled.includes(this.channel.id)) return "I'm already disabled in this channel!";
channel = this.channel;
}
await db.disableChannel(channel);
this.success = true;
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]?.match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
if (!guildDB.disabled.includes(id)) return "I'm not disabled in that channel!";
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
} else {
if (!guildDB.disabled.includes(this.channel.id)) return "I'm not disabled in this channel!";
channel = this.channel;
}
await db.enableChannel(channel);
this.success = true;
return "I have been re-enabled in this channel.";
}
}
static description = "Enables/disables classic commands in a channel (use server settings for slash commands)";
static arguments = ["[enable/disable]", "{id}"];
static slashAllowed = false;
static directAllowed = false;
static dbRequired = true;
}
export default ChannelCommand;

View file

@ -1,44 +0,0 @@
import db from "../../utils/database.js";
import Command from "../../classes/command.js";
import * as collections from "../../utils/collections.js";
class CommandCommand extends Command {
async run() {
this.success = false;
if (!this.guild) return "This command only works in servers!";
const owners = process.env.OWNER.split(",");
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!";
if (this.args.length === 0) return "You need to provide whether you want to enable/disable a command!";
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
if (!this.args[1]) return "You need to provide what command to enable/disable!";
if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!";
const guildDB = await db.getGuild(this.guild.id);
const disabled = guildDB.disabled_commands ?? guildDB.disabledCommands;
const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase();
if (this.args[0].toLowerCase() === "disable") {
if (command === "command") return "You can't disable that command!";
if (disabled?.includes(command)) return "That command is already disabled!";
await db.disableCommand(this.guild.id, command);
this.success = true;
return `The command has been disabled. To re-enable it, just run \`${guildDB.prefix}command enable ${command}\`.`;
} else if (this.args[0].toLowerCase() === "enable") {
if (!disabled?.includes(command)) return "That command isn't disabled!";
await db.enableCommand(this.guild.id, command);
this.success = true;
return `The command \`${command}\` has been re-enabled.`;
}
}
static description = "Enables/disables a classic command for a server (use server settings for slash commands)";
static aliases = ["cmd"];
static arguments = ["[enable/disable]", "[command]"];
static slashAllowed = false;
static directAllowed = false;
static dbRequired = true;
}
export default CommandCommand;

View file

@ -20,7 +20,7 @@ class DonateCommand extends Command {
} catch (e) { } catch (e) {
// no-op // no-op
} }
return `${prefix}Like esmBot? Consider supporting the developer on Patreon to help keep it running! https://patreon.com/TheEssem`; return `${prefix}Like esmBot (or mrmBot)? Consider supporting Essem on Patreon to help keep it running! https://patreon.com/TheEssem`;
} }
static description = "Learn more about how you can support esmBot's development"; static description = "Learn more about how you can support esmBot's development";

View file

@ -1,27 +0,0 @@
import Command from "../../classes/command.js";
class PingCommand extends Command {
async run() {
if (this.type === "classic") {
const pingMessage = await this.client.rest.channels.createMessage(this.message.channelID, Object.assign({
content: "🏓 Ping?"
}, this.reference));
await pingMessage.edit({
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.message.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.message.guildID]).latency)}ms` : ""}\n\`\`\``
});
} else {
await this.interaction.createMessage({
content: "🏓 Ping?"
});
const pingMessage = await this.interaction.getOriginal();
await this.interaction.editOriginal({
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - Math.floor((this.interaction.id / 4194304) + 1420070400000)}ms${this.interaction.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.interaction.guildID]).latency)}ms` : ""}\n\`\`\``
});
}
}
static description = "Pings Discord's servers";
static aliases = ["pong"];
}
export default PingCommand;

View file

@ -16,7 +16,7 @@ class QrReadCommand extends Command {
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height); const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
if (!qrBuffer) return "I couldn't find a QR code!"; if (!qrBuffer) return "I couldn't find a QR code!";
this.success = true; this.success = true;
return `\`\`\`\n${await clean(qrBuffer.data)}\n\`\`\``; return { html: `<pre><code>${await clean(qrBuffer.data)}</pre></code>` };
} }
static description = "Reads a QR code"; static description = "Reads a QR code";