Add different channel support for pinned command, update host info
This commit is contained in:
parent
49c4c57f94
commit
5b998f4b54
|
@ -1071,7 +1071,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustcord"
|
||||
version = "1.0.2"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"brainfrick 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "rustcord"
|
||||
version = "1.0.2"
|
||||
version = "1.1.0"
|
||||
authors = ["Agatha Rose <EvilDeaaaadd@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -15,7 +15,7 @@ use serenity::{
|
|||
Args, CheckResult, CommandError, CommandOptions, CommandResult, DispatchError, Reason,
|
||||
StandardFramework,
|
||||
},
|
||||
model::{channel::Message, gateway::Ready, id::UserId, user::OnlineStatus},
|
||||
model::{channel::Message, gateway::Ready, id::{ChannelId, UserId}, user::OnlineStatus},
|
||||
prelude::*,
|
||||
};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
|
@ -221,7 +221,7 @@ fn host(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
let _ = message.channel_id.say(
|
||||
&ctx.http,
|
||||
format!(
|
||||
"Debug\nOS: {os}; {release}\nHost: {host}\nCPU: {cpu}MHz",
|
||||
"OS: {os}; {release}\nHost: {host}\nCPU: {cpu}MHz",
|
||||
os = sys_info::os_type().unwrap(),
|
||||
host = sys_info::hostname().unwrap(),
|
||||
release = sys_info::linux_os_release()
|
||||
|
@ -527,8 +527,8 @@ fn help(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
),
|
||||
("owo!desc", "Display channel's topic", true),
|
||||
(
|
||||
"owo!pinned ``[num]``",
|
||||
"Display channel's Nth pinned message",
|
||||
"owo!pinned ``num`` ``<channel>``",
|
||||
"Display channel's Nth pinned message. Channel name is optional",
|
||||
true,
|
||||
),
|
||||
("owo!brainfuck ``input``", "execute input code", true),
|
||||
|
@ -648,7 +648,16 @@ fn desc(ctx: &mut Context, message: &Message) -> CommandResult {
|
|||
|
||||
#[command]
|
||||
fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult {
|
||||
let pinned = match message.channel_id.pins(&ctx.http) {
|
||||
let mut idx = args.single::<usize>().unwrap_or(1);
|
||||
if idx != 0 {
|
||||
idx -= 1;
|
||||
}
|
||||
let target_channel = match args.single::<ChannelId>() {
|
||||
Ok(v) => v,
|
||||
Err(_) => message.channel_id
|
||||
};
|
||||
dbg!(target_channel);
|
||||
let pinned = match target_channel.pins(&ctx.http) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
return Err(CommandError(
|
||||
|
@ -656,10 +665,6 @@ fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult
|
|||
));
|
||||
}
|
||||
};
|
||||
let mut idx = args.single::<usize>().unwrap_or(1);
|
||||
if idx != 0 {
|
||||
idx -= 1;
|
||||
}
|
||||
if pinned.is_empty() {
|
||||
return Err(CommandError("No pinned messages found!".to_string()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue