add getValues command

This commit is contained in:
ShuriZma 2024-06-27 09:19:11 +02:00
parent c51909ac13
commit 687c4e6ac1
Signed by: ShuriZma
GPG Key ID: 8D289758EE9B8074
2 changed files with 88 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import Reset from "./commands/reset";
import SetModRole from "./commands/setModRole";
import SetIgnorePrefix from "./commands/setIgnorePrefix";
import SetAutoEmbedMessages from "./commands/setAutoEmbedMessages";
import GetValues from "./commands/getValues";
import { pagination, ButtonsTypes, ButtonsStyles } from "@devraelfreeze/discordjs-pagination";
export class Bot {
@ -44,6 +45,7 @@ export class Bot {
commands.set(SetModRole.data.name, SetModRole);
commands.set(SetIgnorePrefix.data.name, SetIgnorePrefix);
commands.set(SetAutoEmbedMessages.data.name, SetAutoEmbedMessages);
commands.set(GetValues.data.name, GetValues);
client.once(Events.ClientReady, readyClient => {
@ -123,6 +125,7 @@ export class Bot {
SetModRole.data.toJSON(),
SetIgnorePrefix.data.toJSON(),
SetAutoEmbedMessages.data.toJSON(),
GetValues.data.toJSON(),
);
@ -294,31 +297,55 @@ export class Bot {
return this;
}
public getChannel(): string {
return this.channel;
}
public setCounter(counter: number): Bot {
this.counter = counter;
return this;
}
public getCounter(): number {
return this.counter;
}
public setLastUser(lastUserId: string): Bot {
this.lastUser = lastUserId;
return this;
}
public getLastUser(): string {
return this.lastUser;
}
public setModRole(roleId: string): Bot {
this.modRole = roleId;
return this;
}
public getModRole(): string {
return this.modRole;
}
public setIgnorePrefix(prefix: string): Bot {
this.ignorePrefix = prefix;
return this;
}
public getIgnorePrefix(): string {
return this.ignorePrefix;
}
public setAutoEmbedMessages(counter: number): Bot {
this.autoEmbedMessages = counter;
return this;
}
public getAutoEmbedMessages(): number {
return this.autoEmbedMessages;
}
public static getInstance(): Bot {
if (!Bot.instance) {
Bot.instance = new Bot();

61
src/commands/getValues.ts Normal file
View File

@ -0,0 +1,61 @@
import {
ChatInputCommandInteraction, EmbedBuilder,
PermissionsBitField,
SlashCommandBuilder,
SlashCommandChannelOption,
} from 'discord.js';
import {ChannelType} from 'discord-api-types/v10';
import {Bot} from "../bot";
export default {
data: new SlashCommandBuilder()
.setName('getvalues')
.setDescription('Show all the currently set properties of the bot.')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator),
async execute(interaction: ChatInputCommandInteraction) {
const bot = Bot.getInstance();
console.log('channel: ' + bot .getChannel() + ' counter: ' + bot.getCounter() + ' lastUser: ' + bot.getLastUser() + ' modRole: ' + bot.getModRole() + ' ignorePrefix: ' + bot.getIgnorePrefix() + ' autoEmbedMessages: ' + bot.getAutoEmbedMessages());
const embed = new EmbedBuilder()
.setTitle('Bot Properties')
.setDescription('This is a list of all the bots currently set properties')
.setColor(0xffe600)
.setFields([
{
name: 'channel',
value: bot.getChannel(),
inline: true,
},
{
name: 'counter',
value: bot.getCounter().toString(),
inline: true,
},
{
name: 'lastUser',
value: '<@' + bot.getLastUser() + '>',
inline: true,
},
{
name: 'modRole',
value: '<@&' + bot.getModRole() + '>',
inline: true,
},
{
name: 'ignorePrefix',
value: bot.getIgnorePrefix(),
inline: true,
},
{
name: 'autoEmbedMessages',
value: bot.getAutoEmbedMessages().toString(),
inline: true,
},
]);
return await interaction.reply({
embeds: [embed],
ephemeral: true,
});
},
};