import { Command } from "discord-akairo"; import { Message } from "discord.js"; import { cancelString } from "../../config/Constants"; import { Guild } from "../../entity/Guild"; import { errorEmbed, infoEmbed, successEmbed } from "../Util"; class SetName extends Command { constructor() { super("setName", { category: "Server Settings", aliases: ["SetName"], description: "", clientPermissions: ["CREATE_INSTANT_INVITE", "BAN_MEMBERS"], channel: "guild", args: [ { id: "newName", type: "string", prompt: { start: () => infoEmbed("The new name for the guild:").setFooter(cancelString), }, }, ], }); } async exec(message: Message, { newName }: { newName: string }) { const author = message.member; if (author === null) { return; } if (await Guild.count({ where: { name: newName } })) { return message.reply( errorEmbed("A guild has already registered with that name.") ); } const guild = await Guild.findOneOrFail({ where: { guild: author.guild.id }, }); guild.name = newName; guild.save(); message.reply( successEmbed("Guild Settings Updated") .addField("Name", guild.name, true) .addField("Post Channel", `<#${guild.channel}>`, true) .addField("\u200b", "\u200b", true) .addField("Staff Role", `<@&${guild.staffRole}>`, true) .addField("Restricted Role", `<@&${guild.jailedRole}>`, true) .addField("\u200b", "\u200b", true) .addField("Minimum time before re-appeal", guild.defaultExpiry) ); } } export default SetName;