Different prefix per server

Signed-off-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Ethan Lane 2022-03-19 16:22:03 +00:00
parent a0cf29d586
commit 5d629c3b8f
Signed by: Vylpes
GPG key ID: EED233CC06D12504
3 changed files with 14 additions and 1 deletions

View file

@ -1,6 +1,8 @@
USAGE: <key> <set|reset> [value]
===[ KEYS ]===
bot.prefix: The bot prefix for the server (Default: "v!")
commands.disabled: Disabled commands (Default: "")
commands.disabled.message: The message to show when a disabled command is ran (Default: "This command is disabled.")

View file

@ -1,6 +1,7 @@
import { Message } from "discord.js";
import { IBaseResponse } from "../contracts/IBaseResponse";
import ICommandItem from "../contracts/ICommandItem";
import SettingsHelper from "../helpers/SettingsHelper";
import { Util } from "./util";
export interface IEventResponse extends IBaseResponse {
@ -32,7 +33,14 @@ export class Events {
message: "Message was sent by a bot, ignoring.",
};
const prefix = process.env.BOT_PREFIX as string;
const prefix = await SettingsHelper.GetSetting("bot.prefix", message.guild.id);
if (!prefix) {
return {
valid: false,
message: "Prefix not found",
};
}
if (message.content.substring(0, prefix.length).toLowerCase() == prefix.toLowerCase()) {
const args = message.content.substring(prefix.length).split(" ");

View file

@ -15,6 +15,9 @@ export default class DefaultValues {
private static SetValues() {
if (this.values.length == 0) {
// Bot
this.values.push({ Key: "bot.prefix", Value: "v!" });
// Commands
this.values.push({ Key: "commands.disabled", Value: "" });
this.values.push({ Key: "commands.disabled.message", Value: "This command is disabled." });