finished debug subcommands
This commit is contained in:
@@ -58,10 +58,11 @@ It is required to install all used Python modules. You can find those in [req.tx
|
||||
|
||||
### Required permissions:
|
||||
**These are automatically set if you use the [official invite link](https://discord.com/oauth2/authorize?client_id=1212127255795335208&permissions=84992&integration_type=0&scope=bot) or an invite link with the permissions integer set to `84992`.** (The permission integer is this part of the URL `&permissions=84992`)
|
||||
* Send Messages
|
||||
* Read Message History
|
||||
* View Channels
|
||||
* Create Invites
|
||||
* Embed Links
|
||||
* Read Message History
|
||||
* Send Messages
|
||||
* View Channels
|
||||
|
||||
### Configuration:
|
||||
You can find config files in the [cfg/](cfg/) folder. You can also find the default configs in the [data/defaults/cfg_default.toml](data/defaults/cfg_default.toml) file.\
|
||||
|
||||
+4
-1
@@ -19,6 +19,8 @@
|
||||
"dc_msg_err_trace": "Unknown error!\nError trace: {0}",
|
||||
"dc_msg_failed_shorturl_conversion": "Couldn't convert to shortURL: Invalid Reddit URL format.",
|
||||
"dc_msg_mandatory_response": "Mandatory response message, please ignore.",
|
||||
"dc_msg_no_perms": "Missing permission in that server: {0}",
|
||||
"dc_msg_not_in_guild": "I am not a part of that guild.",
|
||||
"dc_msg_owner_data_save_complete": "Saving data... Done!\nShutting down...",
|
||||
"dc_msg_owner_data_save": "Saving data...",
|
||||
"dc_msg_owner_shutdown_failed_confirmation": "Failed to shut down: Invalid confirmation.",
|
||||
@@ -62,5 +64,6 @@
|
||||
"py_re_response_weekly_add": "Successfully added your post to the weekly art submissions! Thank you for participating!",
|
||||
"py_re_response_weekly_exists": "Couldn't add this post to the submissions! Luckily, it's already there! Thank you for participating!",
|
||||
"py_re_response_weekly_mod_add": "[MOD ACTION] Successfully added this post to the weekly art submissions!",
|
||||
"py_re_response_weekly_mod_unremove": "[MOD ACTION] Successfully un-removed this post from the weekly art submissions!"
|
||||
"py_re_response_weekly_mod_unremove": "[MOD ACTION] Successfully un-removed this post from the weekly art submissions!",
|
||||
"success": "Success!"
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
"dc_msg_err_trace": "Erreur inconnue !\nTrace de l’erreur : {0}",
|
||||
"dc_msg_failed_shorturl_conversion": "Échec de la conversion en shortURL : format d’URL Reddit invalide.",
|
||||
"dc_msg_mandatory_response": "Message de réponse obligatoire, merci d’ignorer.",
|
||||
"dc_msg_no_perms": "Permission manquante sur ce serveur : {0}",
|
||||
"dc_msg_not_in_guild": "Je ne fais pas partie de ce serveur.",
|
||||
"dc_msg_owner_data_save_complete": "Sauvegarde des données... Terminé !\nFermeture...",
|
||||
"dc_msg_owner_data_save": "Sauvegarde des données...",
|
||||
"dc_msg_owner_shutdown_failed_confirmation": "Échec de l’arrêt : confirmation invalide.",
|
||||
@@ -62,5 +64,6 @@
|
||||
"py_re_response_weekly_add": "Post ajouté avec succès aux soumissions hebdomadaires d'art ! Merci pour votre participation !",
|
||||
"py_re_response_weekly_exists": "Impossible d’ajouter ce post, il est déjà présent ! Merci pour votre participation !",
|
||||
"py_re_response_weekly_mod_add": "[ACTION MOD] Post ajouté avec succès aux soumissions hebdomadaires d’art !",
|
||||
"py_re_response_weekly_mod_unremove": "[ACTION MOD] Post restauré avec succès dans les soumissions hebdomadaires d’art !"
|
||||
"py_re_response_weekly_mod_unremove": "[ACTION MOD] Post restauré avec succès dans les soumissions hebdomadaires d’art !",
|
||||
"dc_msg_success": "succès !"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
use poise::serenity_prelude::{CreateInvite, GuildId};
|
||||
|
||||
use crate::{Context, Error, lang, messages::send_msg};
|
||||
|
||||
|
||||
pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> {
|
||||
let id = GuildId::from(guild_id);
|
||||
let guild = id.to_partial_guild(ctx.http()).await?;
|
||||
|
||||
if !ctx.serenity_context().cache.guilds().contains(&id) {
|
||||
send_msg(ctx, lang!("dc_msg_not_in_guild"), true, true).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let ch = guild.channels(ctx.http()).await?
|
||||
.values()
|
||||
.find(|c| c.is_text_based())
|
||||
.cloned();
|
||||
|
||||
if let Some(channel) = ch {
|
||||
let bot_member = &guild.member(ctx.http(), ctx.framework().bot_id).await?;
|
||||
let perms = guild.user_permissions_in(&channel, bot_member);
|
||||
|
||||
if !perms.create_instant_invite() {
|
||||
send_msg(ctx, lang!("dc_msg_no_perms", "CreateInvite"), true, true).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let inv_builder = CreateInvite::new().max_age(0).max_uses(0);
|
||||
let inv = channel.id.create_invite(ctx.http(), inv_builder).await?;
|
||||
send_msg(ctx, inv.url(), true, true).await;
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
use poise::serenity_prelude::GuildId;
|
||||
|
||||
use crate::{Context, Error, lang, messages::send_msg};
|
||||
|
||||
|
||||
pub async fn cmd(ctx: Context<'_>, guild_id: u64) -> Result<(), Error> {
|
||||
let id = GuildId::from(guild_id);
|
||||
let guild = id.to_partial_guild(ctx.http()).await?;
|
||||
|
||||
if !ctx.serenity_context().cache.guilds().contains(&id) {
|
||||
send_msg(ctx, lang!("dc_msg_not_in_guild"), true, true).await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
guild.leave(ctx.http()).await?;
|
||||
send_msg(ctx, lang!("success"), true, true).await;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{Context, Error, debug_cmds::{ping, reload_cfg, stop, whoami}};
|
||||
use crate::{Context, Error, debug_cmds::{guild_invite, leave_guild, ping, reload_cfg, stop, view_guilds, whoami}};
|
||||
|
||||
|
||||
#[derive(poise::ChoiceParameter, PartialEq)]
|
||||
@@ -24,15 +24,21 @@ pub enum Subcommands {
|
||||
pub async fn cmd(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Subcommand"] subcommand: Subcommands,
|
||||
string_arg: Option<String>
|
||||
string_arg: Option<String>,
|
||||
u64_arg: Option<String>
|
||||
) -> Result<(), Error>
|
||||
{
|
||||
let u64_arg_u: u64 = u64_arg.unwrap_or("0".to_string()).as_str().parse()?;
|
||||
|
||||
match subcommand {
|
||||
Subcommands::GuildInvite => guild_invite::cmd(ctx, u64_arg_u).await?,
|
||||
Subcommands::LeaveGuild => leave_guild::cmd(ctx, u64_arg_u).await?,
|
||||
Subcommands::Ping => ping::cmd(ctx).await?,
|
||||
Subcommands::ReloadCfg => reload_cfg::cmd(ctx).await?,
|
||||
Subcommands::Stop => stop::cmd(ctx, string_arg).await?,
|
||||
Subcommands::ViewGuilds => view_guilds::cmd(ctx).await?,
|
||||
Subcommands::WhoAmI => whoami::cmd(ctx).await?,
|
||||
_ => return Ok(())
|
||||
//_ => return Ok(())
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{messages::send_msg, Context, Error};
|
||||
|
||||
|
||||
pub async fn cmd(ctx: Context<'_>,) -> Result<(), Error> {
|
||||
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
|
||||
send_msg(ctx, "Pong".to_string(), true, true).await;
|
||||
|
||||
return Ok(());
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
use crate::{Context, Error, messages::send_msg};
|
||||
|
||||
|
||||
pub async fn cmd(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let guilds = ctx.cache().guilds();
|
||||
let mut msgs: Vec<Vec<String>> = vec![vec![]];
|
||||
let mut char_count: usize = 0;
|
||||
let mut msg_idx: usize = 0;
|
||||
|
||||
for g in guilds {
|
||||
let name = g.name(ctx.cache()).unwrap_or("[unnamed]".to_string());
|
||||
let id = g.get();
|
||||
|
||||
let msg = format!("**[{}]** {}", id, name);
|
||||
char_count += msg.len();
|
||||
|
||||
if char_count >= 2000 {
|
||||
msgs.push(Vec::new());
|
||||
msg_idx += 1;
|
||||
}
|
||||
|
||||
msgs[msg_idx].push(msg);
|
||||
}
|
||||
|
||||
for msg in msgs
|
||||
{ send_msg(ctx, msg.join("\n"), true, true).await; }
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
@@ -22,10 +22,13 @@ mod re_cmds {
|
||||
pub mod vote;
|
||||
}
|
||||
mod debug_cmds {
|
||||
pub mod guild_invite;
|
||||
pub mod leave_guild;
|
||||
pub mod main_cmd;
|
||||
pub mod stop;
|
||||
pub mod ping;
|
||||
pub mod reload_cfg;
|
||||
pub mod view_guilds;
|
||||
pub mod whoami;
|
||||
}
|
||||
mod events;
|
||||
|
||||
Reference in New Issue
Block a user