-
Notifications
You must be signed in to change notification settings - Fork 2
Add ability to synchronize commands #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f758b24
add enabled_commands to config
banocean a411c1e
generate commands list to change in guild
banocean a3a061b
update debug config
banocean bc8dcf3
fix clear command option names
banocean 3224641
query instead of headers auth
banocean 57cba46
Merge branch 'query-auth-for-ws' into commands
banocean 3cee63a
generate bitfields based on what commands should be registered
banocean efc7fef
add ability to set last synced commands
banocean 0b95ab1
is_synced value and SynchronizeCommands action
banocean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Disabled commands indicates what commands should not be registered as guild commands | ||
| #[derive(Serialize, Deserialize, Clone, Debug, Default)] | ||
| pub struct Commands { | ||
| pub case_details: bool, | ||
| pub case_edit: bool, | ||
| pub case_last: bool, | ||
| pub case_list: bool, | ||
| pub case_remove: bool, | ||
|
|
||
| pub clear: bool, | ||
| pub ban: bool, | ||
| pub kick: bool, | ||
| pub mute: bool, | ||
| pub timeout: bool, | ||
| pub warn: bool, | ||
|
|
||
| pub top_day_all: bool, | ||
| pub top_day_me: bool, | ||
| pub top_week_all: bool, | ||
| pub top_week_me: bool | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| use crate::models::config::GuildConfig; | ||
| use crate::server::guild::commands::{default_option, defaults_command, if_enabled}; | ||
| use twilight_model::application::command::{Command, CommandOption, CommandOptionType}; | ||
|
|
||
| macro_rules! subcommand { | ||
| ($name: expr, $description: expr) => { | ||
| CommandOption { | ||
| name: $name.to_string(), | ||
| description: $description.to_string(), | ||
| kind: CommandOptionType::SubCommand, | ||
| ..default_option() | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| macro_rules! group { | ||
| ($name: expr, $subcommands: expr) => { | ||
| CommandOption { | ||
| name: $name.to_string(), | ||
| description: "-".to_string(), | ||
| kind: CommandOptionType::SubCommandGroup, | ||
| options: Some($subcommands), | ||
| ..default_option() | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| pub(super) fn add_activity_commands(config: &GuildConfig, commands: &mut Vec<Command>) { | ||
| if let Some(top) = &config.top { | ||
| let mut subcommand_groups = vec![]; | ||
|
|
||
| if top.day { | ||
| let mut subcommands = vec![]; | ||
|
|
||
| if_enabled!( | ||
| config, | ||
| top_day_all, | ||
| subcommands, | ||
| subcommand!("all", "Shows top 3 active users") | ||
| ); | ||
|
|
||
| if_enabled!( | ||
| config, | ||
| top_day_me, | ||
| subcommands, | ||
| subcommand!("me", "Shows your position on the leaderboard") | ||
| ); | ||
|
|
||
| if !subcommands.is_empty() { | ||
| subcommand_groups.push(group!("day", subcommands)); | ||
| } | ||
| } | ||
|
|
||
| if top.week { | ||
| let mut subcommands = vec![]; | ||
|
|
||
| if_enabled!( | ||
| config, | ||
| top_week_all, | ||
| subcommands, | ||
| subcommand!("all", "Shows top 3 active users") | ||
| ); | ||
|
|
||
| if_enabled!( | ||
| config, | ||
| top_week_me, | ||
| subcommands, | ||
| subcommand!("me", "Shows your position on the leaderboard") | ||
| ); | ||
|
|
||
| if !subcommands.is_empty() { | ||
| subcommand_groups.push(group!("week", subcommands)); | ||
| } | ||
| } | ||
|
|
||
| if !subcommand_groups.is_empty() { | ||
| commands.push(Command { | ||
| name: "top".to_string(), | ||
| description: "-".to_string(), | ||
| options: subcommand_groups, | ||
| ..defaults_command() | ||
| }) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.