mirror of
https://github.com/ethanrusz/echbot.git
synced 2024-11-25 13:17:45 -05:00
Update commands
This commit is contained in:
parent
a2e7d6f531
commit
1cc467ba28
6 changed files with 28 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Group all commands for registration
|
// Group all commands for registration
|
||||||
pub(crate) mod slur;
|
pub(crate) mod slur;
|
||||||
pub(crate) mod team_up;
|
pub(crate) mod team;
|
||||||
pub(crate) mod random;
|
pub(crate) mod random;
|
|
@ -1,16 +1,15 @@
|
||||||
use crate::{Context, Error};
|
use crate::{Context, Error};
|
||||||
|
|
||||||
/// Picks a random something
|
/// Picks a random something
|
||||||
#[poise::command(slash_command, prefix_command, subcommands("god", "mode"))]
|
#[poise::command(slash_command, subcommands("god", "mode"))]
|
||||||
pub(crate) async fn random(
|
pub(crate) async fn random(
|
||||||
ctx: Context<'_>,
|
_ctx: Context<'_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
ctx.say("Pick a subcommand, idiot.").await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Picks a random god to play
|
/// Picks a random god
|
||||||
#[poise::command(slash_command, prefix_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn god(
|
pub(crate) async fn god(
|
||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
@ -18,8 +17,8 @@ pub(crate) async fn god(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Picks a random mode to play
|
/// Picks a random mode
|
||||||
#[poise::command(slash_command, prefix_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn mode(
|
pub(crate) async fn mode(
|
||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Basically a ping command
|
/// Basically a ping command
|
||||||
#[poise::command(slash_command, prefix_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn slur(
|
pub(crate) async fn slur(
|
||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
|
|
19
src/commands/team.rs
Normal file
19
src/commands/team.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use crate::{Context, Error};
|
||||||
|
use crate::serenity;
|
||||||
|
|
||||||
|
/// Splits up players for custom matches
|
||||||
|
#[poise::command(slash_command)]
|
||||||
|
pub(crate) async fn team(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Your voice channel"]
|
||||||
|
#[channel_types("Voice")] channel: serenity::Channel,
|
||||||
|
#[description = "Team size"]
|
||||||
|
#[min = 1] size: u8,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let mut v = ctx.guild().unwrap().voice_states; // Get hashmap of users' voice states within the guild
|
||||||
|
v.retain(|_, s| s.channel_id == Some(channel.id())); // Drop users not active in requested voice channel from hashmap
|
||||||
|
let res = format!("Channel {} has {} active users. Team size is {}.", channel.id(), v.keys().len(), size);
|
||||||
|
|
||||||
|
ctx.say(res).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
use crate::{Context, Error};
|
|
||||||
use crate::serenity;
|
|
||||||
|
|
||||||
/// Split up users for custom joust matches
|
|
||||||
#[poise::command(slash_command, prefix_command)]
|
|
||||||
pub(crate) async fn team_up(
|
|
||||||
ctx: Context<'_>,
|
|
||||||
#[description = "Your voice channel"] channel: Option<serenity::Channel>,
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
let c = channel.as_ref().unwrap(); // Get channel info from object
|
|
||||||
let mut v = ctx.guild().unwrap().voice_states; // Get hashmap of users' voice states within the guild
|
|
||||||
v.retain(|_, s| s.channel_id == Some(c.id())); // Drop users not active in requested voice channel from hashmap
|
|
||||||
let res = format!("Channel {} has {} active users", c.id(), v.keys().len());
|
|
||||||
|
|
||||||
ctx.say(res).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
|
@ -13,7 +13,7 @@ async fn main() {
|
||||||
.options(poise::FrameworkOptions {
|
.options(poise::FrameworkOptions {
|
||||||
commands: vec![
|
commands: vec![
|
||||||
commands::slur::slur(),
|
commands::slur::slur(),
|
||||||
commands::team_up::team_up(),
|
commands::team::team(),
|
||||||
commands::random::random(),
|
commands::random::random(),
|
||||||
], // IntelliJ doesn't like this, but it's fine.
|
], // IntelliJ doesn't like this, but it's fine.
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
Loading…
Reference in a new issue