added a WhoAmI command

This commit is contained in:
2025-07-12 12:04:53 +02:00
parent aad562cb2d
commit 358b16249e
6 changed files with 34 additions and 13 deletions
+7 -9
View File
@@ -1,12 +1,10 @@
# Reddit Commands # Reddit Commands
To execute a command on the Reddit bot, include `u/ByteDiceAssistant [cmd]` in a comment. To execute a command on the Reddit bot, include `u/{BOTNAME} [cmd]` in a comment. (Replace {BOTNAME} with the actual bot name, and [cmd] with any command listed below).
- **`[cmd]`**: The command you want to run and its arguments.
## `bk_week_add` ## `add_post`
Adds the post to the list of posts. Adds a post to the bots database.
- **Only moderators of a subreddit or the OP (Original Poster) can use this command.** - **Only moderators of a subreddit or the OP (Original Poster) can use this command.**
### **Examples** ### **Examples**
``` * `u/{BOTNAME} add_post`
"u/ByteDiceAssistant bk_week_add" * `Cool art, let me add that. u/{BOTNAME} weekly_art` (weekly art is an alias for add_post that is enabled by default)
"Cool art, let me add that. u/ByteDiceAssistant bk_week_add" * `Cool art. Just gonna u/{BOTNAME} add_post so it can become featured.`
"Cool art. Just gonna u/ByteDiceAssistant bk_week_add so it can become featured."
```
+1
View File
@@ -55,6 +55,7 @@
"dc_msg_update_removing_dupe": "{0}Removing duplicate posts...", "dc_msg_update_removing_dupe": "{0}Removing duplicate posts...",
"dc_msg_update_removing_old": "{0}Removing old posts (threshold: {1}d)...", "dc_msg_update_removing_old": "{0}Removing old posts (threshold: {1}d)...",
"dc_msg_update_removing": "{0}Removing removed posts...", "dc_msg_update_removing": "{0}Removing removed posts...",
"dc_msg_whoami": "**Bot \"owner\":** {0}\n**BK moderator:** {1}",
"log_lang_load_success": "Successfully loaded the english language file!", "log_lang_load_success": "Successfully loaded the english language file!",
"none": "None", "none": "None",
"py_re_response_suffix": "^(I am not an AI, I am just a bot. This action was performed automatically by the way. You can report bugs and view my source code [here](https://github.com/ByteDice/ByteDiceAssistant)!)", "py_re_response_suffix": "^(I am not an AI, I am just a bot. This action was performed automatically by the way. You can report bugs and view my source code [here](https://github.com/ByteDice/ByteDiceAssistant)!)",
+4 -4
View File
@@ -8,8 +8,8 @@ use crate::{lang, messages::send_msg, Context, Cmd, Error};
enum HelpOptions { enum HelpOptions {
Admin, Admin,
All, All,
BkWeek, Reddit,
BkWeekReddit, RedditBot,
Generic Generic
} }
@@ -97,8 +97,8 @@ async fn send_single_help(ctx: Context<'_>, mut cmd_name: String) {
async fn send_category_help(ctx: Context<'_>, category: HelpOptions) { async fn send_category_help(ctx: Context<'_>, category: HelpOptions) {
match category { match category {
HelpOptions::BkWeekReddit => send_bk_week_help_re(ctx).await, HelpOptions::RedditBot => send_bk_week_help_re(ctx).await,
HelpOptions::BkWeek => send_bk_week_help (ctx).await, HelpOptions::Reddit => send_bk_week_help (ctx).await,
HelpOptions::Generic => send_generic_help (ctx).await, HelpOptions::Generic => send_generic_help (ctx).await,
HelpOptions::Admin => send_admin_help (ctx).await, HelpOptions::Admin => send_admin_help (ctx).await,
HelpOptions::All => send_all_help (ctx).await HelpOptions::All => send_all_help (ctx).await
+20
View File
@@ -0,0 +1,20 @@
use crate::{lang, messages::send_msg, Context, Error};
#[poise::command(
slash_command,
prefix_command,
rename = "whoami",
category = "help",
required_bot_permissions = "SEND_MESSAGES | VIEW_CHANNEL"
)]
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
let data = ctx.data();
let uid: u64 = ctx.author().id.into();
let is_owner = data.owners .contains(&uid);
let is_bk_mod = data.bk_mods.contains(&uid);
send_msg(ctx, lang!("dc_msg_whoami", is_owner, is_bk_mod), true, true).await;
return Ok(());
}
+1
View File
@@ -79,6 +79,7 @@ async fn make_cmd_vec(data: &Data) -> Vec<Cmd> {
let mut cmds = vec![ let mut cmds = vec![
// GENERIC // GENERIC
cmds::help::cmd(), cmds::help::cmd(),
cmds::whoami::cmd(),
cmds::ping::cmd(), cmds::ping::cmd(),
cmds::eight_ball::cmd(), cmds::eight_ball::cmd(),
// REDDIT // REDDIT
+1
View File
@@ -10,6 +10,7 @@ mod cmds {
pub mod reload_cfg; pub mod reload_cfg;
pub mod send; pub mod send;
pub mod stop; pub mod stop;
pub mod whoami;
} }
mod re_cmds { mod re_cmds {
pub mod add; pub mod add;