WIP: Start of config command tests

This commit is contained in:
Ethan Lane 2024-05-06 16:34:17 +01:00
parent 3afc28e02b
commit 3d8b5a8347
2 changed files with 118 additions and 21 deletions
src/commands

View file

@ -70,7 +70,7 @@ export default class Config extends Command {
await this.SendHelpText(interaction);
break;
case 'reset':
await this.ResetValue(interaction);
await this.ResetValue(interaction, server);
break;
case 'get':
await this.GetValue(interaction);
@ -95,8 +95,6 @@ export default class Config extends Command {
}
private async GetValue(interaction: CommandInteraction) {
if (!interaction.guildId) return;
const key = interaction.options.get('key');
if (!key || !key.value) {
@ -104,7 +102,7 @@ export default class Config extends Command {
return;
}
const server = await Server.FetchOneById<Server>(Server, interaction.guildId, [
const server = await Server.FetchOneById<Server>(Server, interaction.guildId!, [
"Settings",
]);
@ -128,7 +126,7 @@ export default class Config extends Command {
}
}
private async ResetValue(interaction: CommandInteraction) {
private async ResetValue(interaction: CommandInteraction, server: Server) {
if (!interaction.guildId) return;
const key = interaction.options.get('key');
@ -138,15 +136,6 @@ export default class Config extends Command {
return;
}
const server = await Server.FetchOneById<Server>(Server, interaction.guildId, [
"Settings",
]);
if (!server) {
await interaction.reply('Server not found.');
return;
}
const setting = server.Settings.filter(x => x.Key == key.value)[0];
if (!setting) {