You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2b-bot-v2/src/commands/guild/utility/SetPrefix.ts

32 lines
1.2 KiB
TypeScript

import {GuildCommand} from "../../../lib/GuildCommand";
import {CommandPermission} from "../../../lib/CommandPermission";
import {Message} from "discord.js";
import {CommandCategory} from "../../CommandCategory";
export class SetPrefix extends GuildCommand {
public static commandName = "setPrefix";
public static permission = CommandPermission.ADMIN;
public static category = CommandCategory.UTILITY;
public static description = "Sets the command prefix for the guild.";
public static usage = "setPrefix <prefix>";
/**
* Sets the prefix for a guild.
* @param msg
*/
public invoke(msg: Message): Promise<void> | void {
const args = SetPrefix.getArgs(msg.content);
if (args.length > 1) {
const prefix: string = args[1];
if (/^\S+$/.test(prefix)) {
this.guildHandler.settings.prefix = prefix;
msg.channel.send(`Changed the command prefix to **${prefix}**`);
} else {
msg.channel.send(`**${prefix}** Is not a valid prefix. \nA prefix must be a non-whitespace sequence of characters.`);
}
} else {
msg.channel.send("You need to provide a prefix as commadn argument.");
}
}
}