--- /dev/null
+#![feature(prelude_import)]
+#[prelude_import]
+use std::prelude::rust_2021::*;
+#[macro_use]
+extern crate std;
+mod utils {
+
+ // let avatar = EmbedData::get_author_avatar_url(&ctx).await;
+
+ // match ctx.send(|f| f.embed(
+ // |f| f.author(
+ // |f| f.name(
+ // format! {"{} | v{}",
+ // match &ctx.author().member {
+ // None => { &ctx.author().name }
+ // Some(m) => {
+ // match &m.nick {
+ // None => { &ctx.author().name }
+ // Some(n) => { &n }
+ // }
+ // }
+ // },
+ // &ctx.data().podman_version
+ // }).icon_url(avatar)
+ // ).title(
+ // format!("Podman {}", match &v.version {
+ // None => { "unknown" }
+ // Some(v) => { v }
+ // })
+ // ).field(
+ // "Podman Version",
+ // format!("Podman v{}", match &v.version {
+ // None => { "unknown" }
+ // Some(v) => { v }
+ // }),
+ // true,
+ // ).field(
+ // "Api Version",
+ // format!("API v{}", match &v.api_version {
+ // None => { "unknown" }
+ // Some(v) => { v }
+ // }),
+ // true,
+ // )
+ // )).await {
+ // Ok(_) => { Ok(()) }
+ // Err(e) => { Err(Error::try_from(e).unwrap()) }
+ // }
+
+ use podman_api::Podman;
+ use poise::serenity_prelude as serenity;
+ pub(crate) struct EmbedData;
+ impl EmbedData {
+ pub(crate) async fn get_author_avatar_url(ctx: &Context<'_>) -> String {
+ match ctx.author_member().await {
+ None => {
+ match "none" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 11u32, "\"none\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ match ctx.author().avatar_url() {
+ None => {
+ match "none" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 14u32, "\"none\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ ctx.author().default_avatar_url()
+ }
+ Some(url) => {
+ match "some" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 18u32, "\"some\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ url
+ }
+ }
+ }
+ Some(member) => {
+ match "some" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 24u32, "\"some\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ match member.avatar_url() {
+ None => {
+ match "none" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 27u32, "\"none\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ match ctx.author().avatar_url() {
+ None => {
+ match "none" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 30u32, "\"none\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ ctx.author().default_avatar_url()
+ }
+ Some(url) => {
+ match "some" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 34u32, "\"some\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ url
+ }
+ }
+ }
+ Some(url) => {
+ match "some" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/utils.rs", 40u32, "\"some\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ url
+ }
+ }
+ }
+ }
+ }
+ }
+ pub(crate) struct Data {
+ pub(crate) podman: Podman,
+ pub(crate) podman_version: String,
+ }
+ pub(crate) type Error = Box<dyn std::error::Error + Send + Sync>;
+ pub(crate) type Context<'a> = poise::Context<'a, Data, Error>;
+ #[macro_export]
+ macro_rules! create_embed {
+ ($ctx : expr, $title : expr,
+ $($field_title : expr => $field_data : expr), *) =>
+ {
+ let avatar = EmbedData :: get_author_avatar_url($ctx).await ;
+ match
+ $ctx.send(| f |
+ f.embed(| f |
+ f.author(| f |
+ f.name(format!
+ ("{} | v{}", match $ctx.author().member
+ {
+ None => { $ctx.author().name } Some(m) =>
+ {
+ match & m.nick
+ { None => { $ctx.author().name } Some(n) => { & n } }
+ }
+ },
+ $ctx.data().podman_version)))).icon_url(avatar)).title($title).$(field($field_title,
+ $field_data, true)) *.await
+ {
+ Ok(_) => { Ok(()) } Err(e) =>
+ { Err(Error :: try_from(e).unwrap()) }
+ }
+ } ;
+ }
+}
+use std::process;
+use poise::serenity_prelude as serenity;
+use tokio;
+use podman_api::Podman;
+use poise::serenity_prelude::EntityType::Str;
+use crate::utils::*;
+#[allow(clippy::str_to_string)]
+fn version() -> ::poise::Command<
+ <Context<'static> as poise::_GetGenerics>::U,
+ <Context<'static> as poise::_GetGenerics>::E,
+> {
+ /// Display's the connected podman's version information
+ async fn inner(ctx: Context<'_>) -> Result<(), Error> {
+ match "Command status is being run" {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/main.rs", 16u32, "\"Command status is being run\"", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ let v = match ctx.data().podman.version().await {
+ Ok(v) => v,
+ Err(e) => {
+ return match ctx
+ .send(|f| {
+ f.embed(|f| {
+ f.author(|f| {
+ f.name(match &ctx.author().member {
+ None => "unknown",
+ Some(m) => match &m.nick {
+ None => &ctx.author().name,
+ Some(n) => n,
+ },
+ })
+ })
+ .description(format_args!("```{0}```", e))
+ .title("An error has occurred")
+ })
+ })
+ .await
+ {
+ Ok(_) => Ok(()),
+ Err(e) => Err(Error::try_from(e).unwrap()),
+ };
+ }
+ };
+ match &v {
+ tmp => {
+ {
+ ::std::io::_eprint(format_args!(
+ "[{0}:{1}] {2} = {3:#?}\n",
+ "src/main.rs", 43u32, "&v", &tmp
+ ));
+ };
+ tmp
+ }
+ };
+ (/*ERROR*/);
+ Ok(())
+ }
+ ::poise::Command {
+ prefix_action: Some(|ctx| {
+ Box::pin(async move {
+ let (..) = async {
+ use ::poise::PopArgument as _;
+ let ctx = ctx.serenity_context;
+ let msg = ctx.msg;
+ let args = ctx.args;
+ let attachment_index = 0;
+ let mut error: (Box<dyn std::error::Error + Send + Sync>, Option<String>) =
+ (Box::new(::poise::TooManyArguments) as _, None);
+ if args.is_empty() {
+ return Ok(());
+ };
+ Err(error)
+ }
+ .await
+ .map_err(|(error, input)| {
+ poise::FrameworkError::ArgumentParse {
+ error,
+ input,
+ ctx: ctx.into(),
+ }
+ })?;
+ if !ctx.framework.options.manual_cooldowns {
+ ctx.command
+ .cooldowns
+ .lock()
+ .unwrap()
+ .start_cooldown(ctx.into());
+ }
+ inner(ctx.into())
+ .await
+ .map_err(|error| poise::FrameworkError::Command {
+ error,
+ ctx: ctx.into(),
+ })
+ })
+ }),
+ slash_action: Some(|ctx| {
+ Box::pin(async move {
+ #[allow(clippy::needless_question_mark)]
+ let () = async {
+ use ::poise::SlashArgumentHack;
+ let (ctx, interaction, args) =
+ (ctx.serenity_context, ctx.interaction, ctx.args);
+ Ok::<_, ::poise::SlashArgError>(())
+ }
+ .await
+ .map_err(|error| match error {
+ poise::SlashArgError::CommandStructureMismatch(description) => {
+ poise::FrameworkError::CommandStructureMismatch { ctx, description }
+ }
+ poise::SlashArgError::Parse { error, input } => {
+ poise::FrameworkError::ArgumentParse {
+ ctx: ctx.into(),
+ error,
+ input: Some(input),
+ }
+ }
+ })?;
+ if !ctx.framework.options.manual_cooldowns {
+ ctx.command
+ .cooldowns
+ .lock()
+ .unwrap()
+ .start_cooldown(ctx.into());
+ }
+ inner(ctx.into())
+ .await
+ .map_err(|error| poise::FrameworkError::Command {
+ error,
+ ctx: ctx.into(),
+ })
+ })
+ }),
+ context_menu_action: None,
+ subcommands: ::alloc::vec::Vec::new(),
+ name: "version".to_string(),
+ name_localizations: std::collections::HashMap::from([]),
+ qualified_name: String::from("version"),
+ identifying_name: String::from("version"),
+ category: None,
+ description: Some("Display's the connected podman's version information".to_string()),
+ description_localizations: std::collections::HashMap::from([]),
+ help_text: None,
+ hide_in_help: false,
+ cooldowns: std::sync::Mutex::new(::poise::Cooldowns::new(::poise::CooldownConfig {
+ global: None.map(std::time::Duration::from_secs),
+ user: None.map(std::time::Duration::from_secs),
+ guild: None.map(std::time::Duration::from_secs),
+ channel: None.map(std::time::Duration::from_secs),
+ member: None.map(std::time::Duration::from_secs),
+ })),
+ reuse_response: false,
+ default_member_permissions: poise::serenity_prelude::Permissions::empty(),
+ required_permissions: poise::serenity_prelude::Permissions::empty(),
+ required_bot_permissions: poise::serenity_prelude::Permissions::empty(),
+ owners_only: false,
+ guild_only: false,
+ dm_only: false,
+ nsfw_only: false,
+ checks: ::alloc::vec::Vec::new(),
+ on_error: None,
+ parameters: ::alloc::vec::Vec::new(),
+ custom_data: Box::new(()),
+ aliases: &[],
+ invoke_on_edit: false,
+ track_deletion: false,
+ broadcast_typing: false,
+ context_menu_name: None,
+ ephemeral: false,
+ __non_exhaustive: (),
+ }
+}
+async fn main() -> Result<(), Err()> {
+ let podman = match Podman::new("unix:///run/podman/podman.sock") {
+ Ok(a) => a,
+ Err(e) => {
+ {
+ ::std::io::_eprint(format_args!("An error has occurred: {0}\n", e));
+ };
+ process::exit(32);
+ }
+ };
+ let framework = poise::Framework::builder()
+ .options(poise::FrameworkOptions {
+ commands: <[_]>::into_vec(
+ #[rustc_box]
+ ::alloc::boxed::Box::new([version()]),
+ ),
+ ..Default::default()
+ })
+ .token(std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN"))
+ .intents(serenity::GatewayIntents::non_privileged())
+ .setup(|ctx, _ready, framework| {
+ Box::pin(async move {
+ poise::builtins::register_globally(ctx, &framework.options().commands).await?;
+ Ok(Data {
+ podman,
+ podman_version: match podman.version().await {
+ Ok(v) => match v.version {
+ None => String::from("Unknown"),
+ Some(v) => v,
+ },
+ Err(e) => {
+ {
+ ::std::io::_eprint(format_args!("An error has occurred: {0}\n", e));
+ };
+ process::exit(31);
+ }
+ },
+ })
+ })
+ });
+ framework.run().await.unwrap();
+}