WIP: Start of config tests
All checks were successful
Test / build (push) Successful in 16s

This commit is contained in:
Ethan Lane 2024-05-07 18:13:41 +01:00
parent 3d8b5a8347
commit 2377ec165f
2 changed files with 273 additions and 38 deletions

View file

@ -73,10 +73,10 @@ export default class Config extends Command {
await this.ResetValue(interaction, server);
break;
case 'get':
await this.GetValue(interaction);
await this.GetValue(interaction, server);
break;
case 'set':
await this.SetValue(interaction);
await this.SetValue(interaction, server);
break;
default:
await interaction.reply('Subcommand not found.');
@ -94,7 +94,7 @@ export default class Config extends Command {
await interaction.reply({ embeds: [ embed ]});
}
private async GetValue(interaction: CommandInteraction) {
private async GetValue(interaction: CommandInteraction, server: Server) {
const key = interaction.options.get('key');
if (!key || !key.value) {
@ -102,15 +102,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) {
@ -148,9 +139,7 @@ export default class Config extends Command {
await interaction.reply('The setting has been reset to the default.');
}
private async SetValue(interaction: CommandInteraction) {
if (!interaction.guildId) return;
private async SetValue(interaction: CommandInteraction, server: Server) {
const key = interaction.options.get('key');
const value = interaction.options.get('value');
@ -159,15 +148,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) {