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 // yet another very hacky command
run() { run() {
return new Promise((resolve) => { 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) { if (this.args.length !== 0) {
this.ipc.broadcast("playbroadcast", this.args.join(" ")); this.ipc.broadcast("playbroadcast", this.args.join(" "));
this.ipc.register("broadcastSuccess", () => { this.ipc.register("broadcastSuccess", () => {

View file

@ -4,7 +4,8 @@ import Command from "../../classes/command.js";
class ChannelCommand extends Command { class ChannelCommand extends Command {
async run() { async run() {
if (!this.message.channel.guild) return "This command only works in servers!"; 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.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!"; 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 { class CommandCommand extends Command {
async run() { async run() {
if (!this.message.channel.guild) return "This command only works in servers!"; 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.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!"; 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 { class EvalCommand extends Command {
async run() { 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(" "); const code = this.args.join(" ");
try { try {
const evaled = eval(code); const evaled = eval(code);

View file

@ -3,7 +3,8 @@ import Command from "../../classes/command.js";
class EvalRawCommand extends Command { class EvalRawCommand extends Command {
async run() { 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(" "); const code = this.args.join(" ");
try { try {
const evaled = eval(code); const evaled = eval(code);

View file

@ -6,7 +6,8 @@ import Command from "../../classes/command.js";
class ExecCommand extends Command { class ExecCommand extends Command {
async run() { 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(" "); const code = this.args.join(" ");
try { try {
const execed = await exec(code); const execed = await exec(code);

View file

@ -2,7 +2,8 @@ import Command from "../../classes/command.js";
class ImageReloadCommand extends Command { class ImageReloadCommand extends Command {
async run() { 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); const amount = await this.ipc.command("image", { type: "reload" }, true);
if (amount > 0) { if (amount > 0) {
return `Successfully connected to ${amount} image servers.`; return `Successfully connected to ${amount} image servers.`;

View file

@ -7,7 +7,7 @@ const exec = promisify(baseExec);
class InfoCommand extends Command { class InfoCommand extends Command {
async run() { 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(); const stats = await this.ipc.getStats();
return { return {
"embed": { "embed": {

View file

@ -6,7 +6,8 @@ class PrefixCommand extends Command {
if (!this.message.channel.guild) return "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); const guild = await database.getGuild(this.message.channel.guild.id);
if (this.args.length !== 0) { 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); await database.setPrefix(this.args[0], this.message.channel.guild);
return `The prefix has been changed to ${this.args[0]}.`; return `The prefix has been changed to ${this.args[0]}.`;
} else { } else {

View file

@ -4,7 +4,8 @@ class ReloadCommand extends Command {
// quite possibly one of the hackiest commands in the bot // quite possibly one of the hackiest commands in the bot
run() { run() {
return new Promise((resolve) => { 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!"); if (this.args.length === 0) resolve("You need to provide a command to reload!");
this.ipc.broadcast("reload", this.args[0]); this.ipc.broadcast("reload", this.args[0]);
this.ipc.register("reloadSuccess", () => { this.ipc.register("reloadSuccess", () => {

View file

@ -2,7 +2,8 @@ import Command from "../../classes/command.js";
class RestartCommand extends Command { class RestartCommand extends Command {
async run() { 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({ await this.client.createMessage(this.message.channel.id, Object.assign({
content: "esmBot is restarting." content: "esmBot is restarting."
}, this.reference)); }, this.reference));

View file

@ -4,7 +4,8 @@ class SoundReloadCommand extends Command {
// another very hacky command // another very hacky command
run() { run() {
return new Promise((resolve) => { 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.client.sendChannelTyping(this.message.channel.id);
this.ipc.broadcast("soundreload"); this.ipc.broadcast("soundreload");
this.ipc.register("soundReloadSuccess", (msg) => { this.ipc.register("soundReloadSuccess", (msg) => {

View file

@ -11,7 +11,7 @@ class StatsCommand extends Command {
async run() { async run() {
const uptime = process.uptime() * 1000; const uptime = process.uptime() * 1000;
const connUptime = this.client.uptime; 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(); const stats = await this.ipc.getStats();
return { return {
embed: { 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!"; 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()); const getResult = await database.getTag(this.message.channel.guild.id, this.args[1].toLowerCase());
if (!getResult) return "This tag doesn't exist!"; 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); await database.removeTag(this.args[1].toLowerCase(), this.message.channel.guild);
return `The tag \`${this.args[1].toLowerCase()}\` has been deleted!`; return `The tag \`${this.args[1].toLowerCase()}\` has been deleted!`;
} else if (this.args[0].toLowerCase() === "edit") { } 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!"; 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()); const getResult = await database.getTag(this.message.channel.guild.id, this.args[1].toLowerCase());
if (!getResult) return "This tag doesn't exist!"; 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); 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!`; return `The tag \`${this.args[1].toLowerCase()}\` has been edited!`;
} else if (this.args[0].toLowerCase() === "own" || this.args[0].toLowerCase() === "owner") { } else if (this.args[0].toLowerCase() === "own" || this.args[0].toLowerCase() === "owner") {