nice new update
This commit is contained in:
parent
e136522421
commit
666638c956
136 changed files with 4483 additions and 9190 deletions
48
src/bot/commands/setprefix.ts
Normal file
48
src/bot/commands/setprefix.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { Client, ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
import { schemas } from "../../database/index";
|
||||
//@ts-expect-error
|
||||
import YALAS from 'mcstatusbot-logger';
|
||||
import { GuildInstance } from "../../database/schemas/Guild";
|
||||
import { UserInstance } from "../../database/schemas/User";
|
||||
|
||||
|
||||
const data = {
|
||||
serverOnly: false,
|
||||
guildId: null,
|
||||
allowSuspendedUserAccess: true,
|
||||
command: new SlashCommandBuilder()
|
||||
.setName('setprefix')
|
||||
.setDescription("sets the message prefix for your server")
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
|
||||
.addStringOption(o =>
|
||||
o.setName('prefix')
|
||||
.setDescription("the prefix eg . or !")
|
||||
.setRequired(true)
|
||||
)
|
||||
}
|
||||
|
||||
export { data };
|
||||
|
||||
|
||||
export async function chatInputCommand(client: Client, interaction: ChatInputCommandInteraction, guild: GuildInstance, user: UserInstance) {
|
||||
const prefix = interaction.options.getString('prefix');
|
||||
if (prefix == undefined) return;
|
||||
const prefixLower = prefix.toLowerCase();
|
||||
|
||||
if (prefix.length > 3) return interaction.reply("the is to long, limit is 3");
|
||||
if (guild.prefix === prefixLower) return interaction.reply("the prefix `" + guild.prefix + "` has been set");
|
||||
|
||||
|
||||
try {
|
||||
await schemas['Guild'].update({
|
||||
prefix: prefixLower
|
||||
}, {
|
||||
where: { id: guild.id }
|
||||
});
|
||||
return interaction.reply("the prefix `" + prefixLower + "` has been set");
|
||||
} catch (err: any) {
|
||||
YALAS.error(err.stack || err);
|
||||
return interaction.reply("failed to update prefix.");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue