Skip to content

Commit

Permalink
Add settings list command
Browse files Browse the repository at this point in the history
  • Loading branch information
l7ssha committed Nov 14, 2024
1 parent a6c45eb commit 33e9344
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
20 changes: 20 additions & 0 deletions lib/src/commands/feature_settings.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:injector/injector.dart';
import 'package:nyxx/nyxx.dart';
import 'package:nyxx_commands/nyxx_commands.dart';
Expand Down Expand Up @@ -88,5 +89,24 @@ final featureSettings = ChatGroup(
return context.respond(paginator);
}),
options: CommandOptions(defaultResponseLevel: ResponseLevel.private)),
ChatCommand(
'list',
'List available settings',
id('settings-list', (ChatContext context) async {
final embeds = Setting.values.map((s) {
return EmbedBuilder(title: s.name, description: s.description, fields: [
if (s.requiresData)
EmbedFieldBuilder(name: 'Example data (if requires)', value: s.example!, isInline: true),
if (s.requiresData)
EmbedFieldBuilder(name: 'Data type (if requires)', value: s.type.toString(), isInline: true),
]);
});

final builders = embeds.slices(4).map((embeds) => MessageBuilder(embeds: embeds)).toList();

final paginator = await pagination.builders(builders);
return context.respond(paginator);
}),
),
],
);
18 changes: 12 additions & 6 deletions lib/src/models/feature_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ enum DataType {

enum Setting {
poopName('poop_name', 'Replace nickname of a member with poop emoji if the member tries to hoist itself', false),
joinLogs('join_logs', 'Logs member join events into specified channel', true, DataType.channelMention),
modLogs('mod_logs', 'Logs administration event into specified channel', true, DataType.channelMention),
joinLogs('join_logs', 'Logs member join events into specified channel', true,
type: DataType.channelMention, example: '419506523467939853'),
modLogs('mod_logs', 'Logs administration event into specified channel', true,
type: DataType.channelMention, example: '419506523467939853'),
jellyfin('jellyfin', 'Allows usage of jellyfin commands', true,
DataType.json), // {"create_instance_role":"419506523467939853"}
type: DataType.json, example: '{"create_instance_role":"419506523467939853"}'),
mentions('mentions', 'Monitors messages for mention abuse', false),
kavita('kavita', 'Allows usage of jellyfin command', true,
DataType.json), // {"create_instance_role":"419506523467939853"}
type: DataType.json, example: '{"create_instance_role":"419506523467939853"}'),
emojiReact('emoji_react', 'React to predefined words with emojis', true,
DataType.string); //{"use_builtin": true|false, "mode": "react|message", "process_other_bots": false}
type: DataType.json,
example: '{"use_builtin": true|false, "mode": "react|message", "process_other_bots": true|false}');

/// name of setting
final String name;
Expand All @@ -32,7 +35,10 @@ enum Setting {
/// Type of data
final DataType? type;

const Setting(this.name, this.description, this.requiresData, [this.type]);
/// Example data for setting
final String? example;

const Setting(this.name, this.description, this.requiresData, {this.example, this.type});
}

/// The value of a setting within a guild.
Expand Down

0 comments on commit 33e9344

Please sign in to comment.