Allow for multiple bot owners to be set

This commit is contained in:
Essem 2021-11-02 19:43:37 -05:00
parent fa14ce7c35
commit 340ef45b17
No known key found for this signature in database
GPG Key ID: 7D497397CC3A2A8C
14 changed files with 28 additions and 15 deletions

View File

@ -4,7 +4,8 @@ class BroadcastCommand extends Command {
// yet another very hacky command
run() {
return new Promise((resolve) => {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can broadcast messages!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can broadcast messages!";
if (this.args.length !== 0) {
this.ipc.broadcast("playbroadcast", this.args.join(" "));
this.ipc.register("broadcastSuccess", () => {

View File

@ -4,7 +4,8 @@ import Command from "../../classes/command.js";
class ChannelCommand extends Command {
async run() {
if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to enable/disable me!";
const owners = process.env.OWNER.split(",");
if (!this.message.member.permissions.has("administrator") && !owners.includes(this.message.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!";

View File

@ -5,7 +5,8 @@ import * as collections from "../../utils/collections.js";
class CommandCommand extends Command {
async run() {
if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to enable/disable me!";
const owners = process.env.OWNER.split(",");
if (!this.message.member.permissions.has("administrator") && !owners.includes(this.message.member.id)) return "You need to be an administrator to enable/disable me!";
if (this.args.length === 0) return "You need to provide what command to enable/disable!";
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";

View File

@ -3,7 +3,8 @@ import Command from "../../classes/command.js";
class EvalCommand extends Command {
async run() {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use eval!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can use eval!";
const code = this.args.join(" ");
try {
const evaled = eval(code);

View File

@ -3,7 +3,8 @@ import Command from "../../classes/command.js";
class EvalRawCommand extends Command {
async run() {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use evalraw!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can use evalraw!";
const code = this.args.join(" ");
try {
const evaled = eval(code);

View File

@ -6,7 +6,8 @@ import Command from "../../classes/command.js";
class ExecCommand extends Command {
async run() {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can use exec!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can use exec!";
const code = this.args.join(" ");
try {
const execed = await exec(code);

View File

@ -2,7 +2,8 @@ import Command from "../../classes/command.js";
class ImageReloadCommand extends Command {
async run() {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload the image servers!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can reload the image servers!";
const amount = await this.ipc.command("image", { type: "reload" }, true);
if (amount > 0) {
return `Successfully connected to ${amount} image servers.`;

View File

@ -7,7 +7,7 @@ const exec = promisify(baseExec);
class InfoCommand extends Command {
async run() {
const owner = await this.ipc.fetchUser(process.env.OWNER);
const owner = await this.ipc.fetchUser(process.env.OWNER.split(",")[0]);
const stats = await this.ipc.getStats();
return {
"embed": {

View File

@ -6,7 +6,8 @@ class PrefixCommand extends Command {
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.permissions.has("administrator") && this.message.member.id !== process.env.OWNER) return "You need to be an administrator to change the bot prefix!";
const owners = process.env.OWNER.split(",");
if (!this.message.member.permissions.has("administrator") && !owners.includes(this.message.member.id)) 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 {

View File

@ -4,7 +4,8 @@ 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("Only the bot owner can reload commands!");
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) 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", this.args[0]);
this.ipc.register("reloadSuccess", () => {

View File

@ -2,7 +2,8 @@ import Command from "../../classes/command.js";
class RestartCommand extends Command {
async run() {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can restart me!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can restart me!";
await this.client.createMessage(this.message.channel.id, Object.assign({
content: "esmBot is restarting."
}, this.reference));

View File

@ -4,7 +4,8 @@ class SoundReloadCommand extends Command {
// another very hacky command
run() {
return new Promise((resolve) => {
if (this.message.author.id !== process.env.OWNER) return "Only the bot owner can reload Lavalink!";
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) return "Only the bot owner can reload Lavalink!";
this.client.sendChannelTyping(this.message.channel.id);
this.ipc.broadcast("soundreload");
this.ipc.register("soundReloadSuccess", (msg) => {

View File

@ -11,7 +11,7 @@ class StatsCommand extends Command {
async run() {
const uptime = process.uptime() * 1000;
const connUptime = this.client.uptime;
const owner = await this.ipc.fetchUser(process.env.OWNER);
const owner = await this.ipc.fetchUser(process.env.OWNER.split(",")[0]);
const stats = await this.ipc.getStats();
return {
embed: {

View File

@ -22,14 +22,16 @@ class TagsCommand extends Command {
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to delete!";
const getResult = await database.getTag(this.message.channel.guild.id, this.args[1].toLowerCase());
if (!getResult) return "This tag doesn't exist!";
if (getResult.author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!";
const owners = process.env.OWNER.split(",");
if (getResult.author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && !owners.includes(this.message.author.id)) return "You don't own this tag!";
await database.removeTag(this.args[1].toLowerCase(), this.message.channel.guild);
return `The tag \`${this.args[1].toLowerCase()}\` has been deleted!`;
} else if (this.args[0].toLowerCase() === "edit") {
if (this.args[1] === undefined) return "You need to provide the name of the tag you want to edit!";
const getResult = await database.getTag(this.message.channel.guild.id, this.args[1].toLowerCase());
if (!getResult) return "This tag doesn't exist!";
if (getResult.author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && this.message.author.id !== process.env.OWNER) return "You don't own this tag!";
const owners = process.env.OWNER.split(",");
if (getResult.author !== this.message.author.id && !this.message.member.permissions.has("manageMessages") && !owners.includes(this.message.author.id)) return "You don't own this tag!";
await this.setTag(this.args.slice(2).join(" "), this.args[1].toLowerCase(), this.message, true);
return `The tag \`${this.args[1].toLowerCase()}\` has been edited!`;
} else if (this.args[0].toLowerCase() === "own" || this.args[0].toLowerCase() === "owner") {