Rename IntoPrefixes into PrefixGetter
This commit is contained in:
@@ -28,7 +28,7 @@ pub enum RuntimeError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait IntoPrefixes<T> {
|
pub trait PrefixGetter<T> {
|
||||||
async fn get(
|
async fn get(
|
||||||
&self,
|
&self,
|
||||||
runtime: &Runtime<T>,
|
runtime: &Runtime<T>,
|
||||||
@@ -38,21 +38,21 @@ pub trait IntoPrefixes<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<T> IntoPrefixes<T> for String {
|
impl<T> PrefixGetter<T> for String {
|
||||||
async fn get(&self, _: &Runtime<T>, _: Option<u64>, _: Option<u64>) -> Vec<String> {
|
async fn get(&self, _: &Runtime<T>, _: Option<u64>, _: Option<u64>) -> Vec<String> {
|
||||||
vec![self.to_string()]
|
vec![self.to_string()]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<T> IntoPrefixes<T> for &str {
|
impl<T> PrefixGetter<T> for &str {
|
||||||
async fn get(&self, _: &Runtime<T>, _: Option<u64>, _: Option<u64>) -> Vec<String> {
|
async fn get(&self, _: &Runtime<T>, _: Option<u64>, _: Option<u64>) -> Vec<String> {
|
||||||
vec![self.to_string()]
|
vec![self.to_string()]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<T: Send + Sync + 'static, const N: usize, S: Send + Sync + 'static> IntoPrefixes<S> for [T; N]
|
impl<T: Send + Sync + 'static, const N: usize, S: Send + Sync + 'static> PrefixGetter<S> for [T; N]
|
||||||
where
|
where
|
||||||
T: ToString,
|
T: ToString,
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<F, Fut, T> IntoPrefixes<T> for F
|
impl<F, Fut, T> PrefixGetter<T> for F
|
||||||
where
|
where
|
||||||
F: Fn() -> Fut + Send + Sync + 'static,
|
F: Fn() -> Fut + Send + Sync + 'static,
|
||||||
Fut: Future<Output = Vec<String>> + Send,
|
Fut: Future<Output = Vec<String>> + Send,
|
||||||
@@ -74,7 +74,7 @@ where
|
|||||||
|
|
||||||
pub struct Bot<T: Send + Sync = ()> {
|
pub struct Bot<T: Send + Sync = ()> {
|
||||||
state: Arc<T>,
|
state: Arc<T>,
|
||||||
prefixes: Arc<dyn IntoPrefixes<T> + Send + Sync>,
|
prefixes: Arc<dyn PrefixGetter<T> + Send + Sync>,
|
||||||
intents: Intents,
|
intents: Intents,
|
||||||
commands: Vec<Arc<dyn Command<T>>>,
|
commands: Vec<Arc<dyn Command<T>>>,
|
||||||
components: Vec<Arc<dyn Component<T>>>,
|
components: Vec<Arc<dyn Component<T>>>,
|
||||||
@@ -90,7 +90,7 @@ pub struct Bot<T: Send + Sync = ()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static + Send + Sync> Bot<T> {
|
impl<T: 'static + Send + Sync> Bot<T> {
|
||||||
pub fn new(state: T, prefixes: impl IntoPrefixes<T> + Send + Sync + 'static) -> Self {
|
pub fn new(state: T, prefixes: impl PrefixGetter<T> + Send + Sync + 'static) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state: Arc::new(state),
|
state: Arc::new(state),
|
||||||
prefixes: Arc::new(prefixes),
|
prefixes: Arc::new(prefixes),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use twilight_http::Client;
|
|||||||
use twilight_model::oauth::Application;
|
use twilight_model::oauth::Application;
|
||||||
|
|
||||||
use crate::framework::{
|
use crate::framework::{
|
||||||
bot::IntoPrefixes, commands::Command, interactions::registry::ComponentRegistry,
|
bot::PrefixGetter, commands::Command, interactions::registry::ComponentRegistry,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The application's runtime tools.
|
/// The application's runtime tools.
|
||||||
@@ -38,7 +38,7 @@ pub struct Runtime<T> {
|
|||||||
pub registry: ComponentRegistry<T>,
|
pub registry: ComponentRegistry<T>,
|
||||||
|
|
||||||
/// The command prefixes getter.
|
/// The command prefixes getter.
|
||||||
pub prefixes: Arc<dyn IntoPrefixes<T> + Send + Sync + 'static>,
|
pub prefixes: Arc<dyn PrefixGetter<T> + Send + Sync + 'static>,
|
||||||
|
|
||||||
/// The commands available in the application.
|
/// The commands available in the application.
|
||||||
pub commands: Vec<Arc<dyn Command<T>>>,
|
pub commands: Vec<Arc<dyn Command<T>>>,
|
||||||
|
|||||||
Reference in New Issue
Block a user