Remove .commands

This commit is contained in:
TheKodeToad 2024-05-05 14:52:10 +01:00
parent 213de85a32
commit 94571c64bc
No known key found for this signature in database
GPG key ID: 5E39D70B4C93C38E
10 changed files with 8 additions and 57 deletions

View file

@ -1,22 +0,0 @@
use crate::{Context, Error};
use log::trace;
use poise::samples::HelpConfiguration;
/// View the help menu
#[poise::command(slash_command, prefix_command, track_edits = true)]
pub async fn help(
ctx: Context<'_>,
#[description = "Provide information about a specific command"] command: Option<String>,
) -> Result<(), Error> {
trace!("Running help command");
let configuration = HelpConfiguration {
extra_text_at_bottom: "Use /help for more information about a specific command!",
..Default::default()
};
poise::builtins::help(ctx, command.as_deref(), configuration).await?;
Ok(())
}

View file

@ -4,7 +4,7 @@ use eyre::Result;
use log::trace;
/// It's a joke
#[poise::command(slash_command, prefix_command, track_edits = true)]
#[poise::command(slash_command)]
pub async fn joke(ctx: Context<'_>) -> Result<(), Error> {
trace!("Running joke command");

View file

@ -6,7 +6,7 @@ use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
/// Returns the number of members in the server
#[poise::command(slash_command, prefix_command, guild_only = true, track_edits = true)]
#[poise::command(slash_command, guild_only = true)]
pub async fn members(ctx: Context<'_>) -> Result<(), Error> {
trace!("Running members command");

View file

@ -1,4 +1,3 @@
pub mod help;
pub mod joke;
pub mod members;
pub mod ping;

View file

@ -8,7 +8,7 @@ use poise::CreateReply;
const PING_PREFIX: &str = "<:catstareback:1078622789885497414> Pong!";
/// Replies with pong!
#[poise::command(slash_command, prefix_command, track_edits = true, ephemeral)]
#[poise::command(slash_command, ephemeral)]
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> {
trace!("Running ping command!");

View file

@ -5,7 +5,7 @@ use poise::serenity_prelude::{CreateEmbed, CreateEmbedFooter};
use poise::CreateReply;
/// Gets a Rory photo!
#[poise::command(slash_command, prefix_command, track_edits = true)]
#[poise::command(slash_command)]
pub async fn rory(
ctx: Context<'_>,
#[description = "specify a Rory ID"] id: Option<u64>,

View file

@ -5,7 +5,7 @@ use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
/// Returns GitHub stargazer count
#[poise::command(slash_command, prefix_command, track_edits = true)]
#[poise::command(slash_command)]
pub async fn stars(ctx: Context<'_>) -> Result<(), Error> {
trace!("Running stars command");
let octocrab = &ctx.data().octocrab;

View file

@ -16,12 +16,7 @@ fn tags() -> &'static Vec<Tag> {
}
/// Send a tag
#[poise::command(
slash_command,
prefix_command,
track_edits = true,
help_text_fn = help
)]
#[poise::command(slash_command)]
pub async fn tag(
ctx: Context<'_>,
#[description = "the tag to send"] name: Choice,
@ -78,13 +73,3 @@ pub async fn tag(
Ok(())
}
fn help() -> String {
let tag_list = tags()
.iter()
.map(|tag| format!("`{}`", tag.id))
.collect::<Vec<String>>()
.join(", ");
format!("Available tags: {tag_list}")
}

View file

@ -34,7 +34,6 @@ pub type Command = poise::Command<Data, Error>;
pub fn all() -> Vec<Command> {
vec![
general!(help),
general!(joke),
general!(members),
general!(ping),

View file

@ -1,10 +1,8 @@
use std::{sync::Arc, time::Duration};
use std::sync::Arc;
use eyre::Context as _;
use log::{info, trace, warn};
use poise::{
serenity_prelude as serenity, EditTracker, Framework, FrameworkOptions, PrefixFrameworkOptions,
};
use poise::{serenity_prelude as serenity, Framework, FrameworkOptions};
use tokio::signal::ctrl_c;
#[cfg(target_family = "unix")]
use tokio::signal::unix::{signal, SignalKind};
@ -104,14 +102,6 @@ async fn main() -> eyre::Result<()> {
Box::pin(handlers::handle_event(ctx, event, framework, data))
},
prefix_options: PrefixFrameworkOptions {
prefix: Some(".".into()),
edit_tracker: Some(Arc::from(EditTracker::for_timespan(Duration::from_secs(
3600,
)))),
..Default::default()
},
..Default::default()
};