mrmBot-Matrix/commands/general/prefix.js
IoIxD 16095c0256
Prefix shouldn't be null ever, let alone when message.channel.guild isn't defined. (#276)
* '/eval 9+10' returns 21

* undid 9+10 joke, fixed prefix bug

* nope that's not how it was

* fully undid 9+10 joke oops
2022-06-14 00:03:18 -05:00

24 lines
No EOL
985 B
JavaScript

import database from "../../utils/database.js";
import Command from "../../classes/command.js";
class PrefixCommand extends Command {
async run() {
if (!this.channel.guild) return `The current prefix is \`${process.env.PREFIX}\``;
const guild = await database.getGuild(this.channel.guild.id);
if (this.args.length !== 0) {
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 change the bot prefix!";
await database.setPrefix(this.args[0], this.channel.guild);
return `The prefix has been changed to ${this.args[0]}.`;
} else {
return `The current prefix is \`${guild.prefix}\`.`;
}
}
static description = "Checks/changes the server prefix";
static aliases = ["setprefix", "changeprefix", "checkprefix"];
static arguments = ["{prefix}"];
static slashAllowed = false;
}
export default PrefixCommand;