aboutsummaryrefslogtreecommitdiff
path: root/src/util/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/mod.rs')
-rw-r--r--src/util/mod.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs
index f362ff7..f959a37 100644
--- a/src/util/mod.rs
+++ b/src/util/mod.rs
@@ -32,7 +32,6 @@ use url::Url;
use crate::{
commands::playback::songbird,
PoiseContext,
- Result,
CONFIG,
};
@@ -47,7 +46,7 @@ pub async fn currently_playing(ctx: PoiseContext<'_>) -> bool {
call.queue().current().is_some()
}
-pub async fn users_listening(ctx: &Context) -> Result<bool> {
+pub async fn users_listening(ctx: &Context) -> anyhow::Result<bool> {
let channel = CONFIG.discord.voice_channel().to_channel(&ctx).await?;
let res = channel
@@ -100,12 +99,12 @@ pub fn err_msg<'a, U, E>(err: &'a FrameworkError<U, E>) -> Option<&'a Message> {
}
#[inline]
-pub fn tts(ctx: PoiseContext<'_>) -> Option<bool> {
+pub fn tts<U, E>(ctx: poise::Context<'_, U, E>) -> Option<bool> {
msg(ctx).map(|msg| msg.tts)
}
#[inline]
-pub fn unwrap_tts(ctx: PoiseContext<'_>) -> bool {
+pub fn unwrap_tts<U, E>(ctx: poise::Context<'_, U, E>) -> bool {
tts(ctx).unwrap_or(false)
}
@@ -115,12 +114,15 @@ pub async fn send(
channel: ChannelId,
text: impl AsRef<str>,
tts: bool,
-) -> Result<()> {
+) -> anyhow::Result<()> {
send_result(ctx, channel, text, tts).await.map(|_| ())
}
#[inline]
-pub async fn reply(ctx: PoiseContext<'_>, text: impl AsRef<str>) -> Result<poise::ReplyHandle> {
+pub async fn reply<U, E>(
+ ctx: poise::Context<'_, U, E>,
+ text: impl AsRef<str>,
+) -> Result<poise::ReplyHandle, serenity::Error> {
let handle =
poise::send_reply(ctx, CreateReply::default().tts(unwrap_tts(ctx)).content(text.as_ref()))
.await?;
@@ -129,7 +131,7 @@ pub async fn reply(ctx: PoiseContext<'_>, text: impl AsRef<str>) -> Result<poise
}
#[inline]
-pub async fn react(ctx: PoiseContext<'_>, react: ReactionType) -> Result<Reaction> {
+pub async fn react(ctx: PoiseContext<'_>, react: ReactionType) -> anyhow::Result<Reaction> {
let react = msg(ctx).ok_or_else(|| anyhow::anyhow!("elp"))?.react(ctx, react).await?;
Ok(react)
}
@@ -139,7 +141,7 @@ pub async fn send_result(
channel: ChannelId,
text: impl AsRef<str>,
tts: bool,
-) -> Result<MessageId> {
+) -> anyhow::Result<MessageId> {
let text = text.as_ref();
debug!("sending message {:?} to channel {:?} (tts: {})", text, channel, tts);
@@ -170,7 +172,7 @@ lazy_static! {
.unwrap();
}
-pub async fn ytdl_url(uri: &str) -> Result<String> {
+pub async fn ytdl_url(uri: &str) -> anyhow::Result<String> {
use serde_json::Value;
use tokio::process::Command;