Skip to content

Commit

Permalink
update serenity
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Nov 17, 2024
1 parent 28711aa commit 9bf95e4
Show file tree
Hide file tree
Showing 28 changed files with 545 additions and 524 deletions.
508 changes: 271 additions & 237 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions core/go.std/silverpelt/config_opts.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package silverpelt

import (
"github.com/bwmarrin/discordgo"
orderedmap "github.com/wk8/go-ordered-map/v2"
"go.std/ext_types"
)

type CanonicalSettingsError struct {
Expand Down Expand Up @@ -67,11 +65,7 @@ type CanonicalInnerColumnTypeStringKind struct {
Kind string `json:"kind"`
Ctx string `json:"ctx"`
} `json:"TemplateRef,omitempty"`
User *struct{} `json:"User,omitempty"`
Channel *struct {
AllowedTypes []discordgo.ChannelType `json:"allowed_types"`
NeededBotPermissions ext_types.Permissions `json:"needed_bot_permissions"`
} `json:"Channel,omitempty"`
User *struct{} `json:"User,omitempty"`
Role *struct{} `json:"Role,omitempty"`
Emoji *struct{} `json:"Emoji,omitempty"`
Message *struct{} `json:"Message,omitempty"`
Expand Down
34 changes: 17 additions & 17 deletions core/rust.binutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
.title("An error has occurred")
.description(error.to_string()),
)
.components(vec![serenity::all::CreateActionRow::Buttons(vec![
serenity::all::CreateButton::new_link(
.components(vec![serenity::all::CreateActionRow::Buttons(
vec![serenity::all::CreateButton::new_link(
&config::CONFIG.meta.support_server_invite,
)
.label("Support Server"),
])]),
.label("Support Server")]
.into(),
)]),
)
.await;

Expand All @@ -48,12 +49,13 @@ pub async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
.title("Command Check Failed")
.description(error.to_string()),
)
.components(vec![serenity::all::CreateActionRow::Buttons(vec![
serenity::all::CreateButton::new_link(
.components(vec![serenity::all::CreateActionRow::Buttons(
vec![serenity::all::CreateButton::new_link(
&config::CONFIG.meta.support_server_invite,
)
.label("Support Server"),
])]),
.label("Support Server")]
.into(),
)]),
)
.await;

Expand Down Expand Up @@ -86,7 +88,7 @@ pub async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
&config::CONFIG.meta.support_server_invite,
)
.label("Support Server"),
])]),
].into())]),
)
.await;

Expand Down Expand Up @@ -130,7 +132,7 @@ Please check out the `User Guide` and use the `Website` to tailor AntiRaid to th
config::CONFIG.meta.support_server_invite.clone(),
)
.label("Support Server")
]
].into()
)
]
)
Expand Down Expand Up @@ -264,23 +266,21 @@ pub fn get_commands(
continue;
}

cmd.category = Some(module.id().to_string());
cmd.category = Some(module.id().into());

let mut subcommands = Vec::new();
// Ensure subcommands are also linked to a category
for subcommand in cmd.subcommands {
let ext_data = extended_data
.get(subcommand.name.as_str())
.unwrap_or_else(|| {
panic!("Subcommand {} does not have extended data", subcommand.name)
});
let ext_data = extended_data.get(&*subcommand.name).unwrap_or_else(|| {
panic!("Subcommand {} does not have extended data", subcommand.name)
});

if ext_data.virtual_command {
continue;
}

subcommands.push(poise::Command {
category: Some(module.id().to_string()),
category: Some(module.id().into()),
..subcommand
});
}
Expand Down
48 changes: 26 additions & 22 deletions core/rust.bot_modules.core/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,29 +402,32 @@ pub async fn commands_modperms(
poise::CreateReply::new()
.content(msg)
.ephemeral(true)
.components(vec![serenity::all::CreateActionRow::Buttons(vec![
serenity::all::CreateButton::new("perms/editraw")
.style(serenity::all::ButtonStyle::Primary)
.label("Open Raw Permission Editor"),
if command_config.disabled.unwrap_or_default() {
serenity::all::CreateButton::new("cmd/enable")
.style(serenity::all::ButtonStyle::Success)
.label("Enable Command")
} else {
serenity::all::CreateButton::new("cmd/disable")
.components(vec![serenity::all::CreateActionRow::Buttons(
vec![
serenity::all::CreateButton::new("perms/editraw")
.style(serenity::all::ButtonStyle::Primary)
.label("Open Raw Permission Editor"),
if command_config.disabled.unwrap_or_default() {
serenity::all::CreateButton::new("cmd/enable")
.style(serenity::all::ButtonStyle::Success)
.label("Enable Command")
} else {
serenity::all::CreateButton::new("cmd/disable")
.style(serenity::all::ButtonStyle::Danger)
.label("Disable Command")
},
serenity::all::CreateButton::new("cmd/reset-toggle")
.style(serenity::all::ButtonStyle::Danger)
.label("Reset Command Toggle"),
serenity::all::CreateButton::new("perms/reset")
.style(serenity::all::ButtonStyle::Danger)
.label("Disable Command")
},
serenity::all::CreateButton::new("cmd/reset-toggle")
.style(serenity::all::ButtonStyle::Danger)
.label("Reset Command Toggle"),
serenity::all::CreateButton::new("perms/reset")
.style(serenity::all::ButtonStyle::Danger)
.label("Reset Command Perms"),
serenity::all::CreateButton::new("cmd/save")
.style(serenity::all::ButtonStyle::Secondary)
.label("Save Command Configuration"),
])])
.label("Reset Command Perms"),
serenity::all::CreateButton::new("cmd/save")
.style(serenity::all::ButtonStyle::Secondary)
.label("Save Command Configuration"),
]
.into(),
)])
}

let msg = ctx
Expand All @@ -434,6 +437,7 @@ pub async fn commands_modperms(
.await?;

let collector = msg
.id
.await_component_interactions(ctx.serenity_context().shard.clone())
.author_id(ctx.author().id)
.timeout(Duration::from_secs(600));
Expand Down
12 changes: 1 addition & 11 deletions core/rust.bot_modules.core/src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn filter(

let res = permission_checks::check_command(
&data.silverpelt_cache,
cmd.qualified_name.as_str(),
&cmd.qualified_name,
guild_id,
ctx.author().id,
&ctx.data().pool,
Expand Down Expand Up @@ -96,13 +96,3 @@ pub async fn help(
)
.await
}

#[poise::command(category = "Help", slash_command, user_cooldown = 1)]
pub async fn simplehelp(
ctx: Context<'_>,
#[description = "Specific command to show help about"]
#[autocomplete = "poise::builtins::autocomplete_command"]
command: Option<String>,
) -> Result<(), Error> {
botox::help::simplehelp(ctx, command).await
}
4 changes: 0 additions & 4 deletions core/rust.bot_modules.core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ impl silverpelt::module::Module for Module {
help::help(),
silverpelt::types::CommandExtendedData::none_map(),
),
(
help::simplehelp(),
silverpelt::types::CommandExtendedData::none_map(),
),
(
stats::stats(),
silverpelt::types::CommandExtendedData::none_map(),
Expand Down
6 changes: 3 additions & 3 deletions core/rust.bot_modules.core/src/modules.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use serenity::all::AutocompleteChoice;
use serenity::all::{AutocompleteChoice, CreateAutocompleteResponse};
use silverpelt::Context;
use silverpelt::Error;

async fn module_list_autocomplete<'a>(
ctx: Context<'_>,
partial: &'a str,
) -> Vec<AutocompleteChoice<'a>> {
) -> CreateAutocompleteResponse<'a> {
let data = ctx.data();
let mut ac = Vec::new();

Expand All @@ -21,7 +21,7 @@ async fn module_list_autocomplete<'a>(
}
}

ac
CreateAutocompleteResponse::new().set_choices(ac)
}

#[poise::command(
Expand Down
4 changes: 2 additions & 2 deletions core/rust.bot_modules.core/src/whois.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn whois_member<'a>(member: &Member) -> CreateEmbed<'a> {
},
true,
)
.field("Created At", member.user.created_at().to_string(), true)
.field("Created At", member.user.id.created_at().to_string(), true)
.field("Bot", member.user.bot().to_string(), true)
.field("Nickname", format!("{:#?}", member.nick), true)
.field("Roles", roles, true)
Expand All @@ -59,7 +59,7 @@ fn whois_user<'a>(user: &User) -> CreateEmbed<'a> {
},
true,
)
.field("Created At", user.created_at().to_string(), true)
.field("Created At", user.id.created_at().to_string(), true)
.field("Bot", user.bot().to_string(), true)
}

Expand Down
2 changes: 1 addition & 1 deletion core/rust.bot_modules.root/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl PostAction for InspectorFakeBotsPostAction {
return Ok(());
}

let data = silverpelt::data::Data::data(ctx.data);
let data = silverpelt::data::Data::get_data(ctx.data);

silverpelt::ar_event::dispatch_event_to_modules_errflatten(std::sync::Arc::new(
silverpelt::ar_event::EventHandlerContext {
Expand Down
Loading

0 comments on commit 9bf95e4

Please sign in to comment.