made the Option<> changes and some stylistics
This commit is contained in:
@@ -5,6 +5,7 @@ CREATE KEYSPACE IF NOT EXISTS payphone
|
|||||||
} AND TABLETS = {
|
} AND TABLETS = {
|
||||||
'enabled': false
|
'enabled': false
|
||||||
};
|
};
|
||||||
|
|
||||||
CREATE TYPE IF NOT EXISTS payphone.message (
|
CREATE TYPE IF NOT EXISTS payphone.message (
|
||||||
id BIGINT,
|
id BIGINT,
|
||||||
|
|
||||||
@@ -27,7 +28,6 @@ CREATE TYPE IF NOT EXISTS payphone.message (
|
|||||||
is_censored BOOLEAN,
|
is_censored BOOLEAN,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS payphone.users (
|
CREATE TABLE IF NOT EXISTS payphone.users (
|
||||||
user_id BIGINT PRIMARY KEY,
|
user_id BIGINT PRIMARY KEY,
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -195,36 +195,36 @@ impl From<TwilightUser> for User {
|
|||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub author_id: i64,
|
pub author_id: i64,
|
||||||
pub author_name: Option<String>,
|
pub author_name: String,
|
||||||
pub author_avatar_url: Option<String>,
|
pub author_avatar_url: String,
|
||||||
pub author_mask: Option<String>,
|
pub author_mask: Option<String>,
|
||||||
pub content: Option<String>,
|
pub content: String,
|
||||||
pub attachments: Option<Vec<String>>,
|
pub attachments: Option<Vec<String>>,
|
||||||
pub sticker: Option<i64>,
|
pub sticker: Option<i64>,
|
||||||
pub propagation_message_id: Option<i64>,
|
pub propagation_message_id: Option<i64>,
|
||||||
pub propagation_channel_id: Option<i64>,
|
pub propagation_channel_id: Option<i64>,
|
||||||
pub replying_to_id: Option<i64>,
|
pub replying_to_id: Option<i64>,
|
||||||
pub is_deleted: Option<bool>,
|
pub is_deleted: bool,
|
||||||
pub is_edited: Option<bool>,
|
pub is_edited: bool,
|
||||||
pub is_censored: Option<bool>,
|
pub is_censored: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Object<'a> for Message {
|
impl<'a> Object<'a> for Message {
|
||||||
type Row = (
|
type Row = (
|
||||||
i64,
|
i64,
|
||||||
i64,
|
i64,
|
||||||
|
String,
|
||||||
|
String,
|
||||||
Option<String>,
|
Option<String>,
|
||||||
Option<String>,
|
String,
|
||||||
Option<String>,
|
|
||||||
Option<String>,
|
|
||||||
Option<Vec<String>>,
|
Option<Vec<String>>,
|
||||||
Option<i64>,
|
Option<i64>,
|
||||||
Option<i64>,
|
Option<i64>,
|
||||||
Option<i64>,
|
Option<i64>,
|
||||||
Option<i64>,
|
Option<i64>,
|
||||||
Option<bool>,
|
bool,
|
||||||
Option<bool>,
|
bool,
|
||||||
Option<bool>,
|
bool,
|
||||||
);
|
);
|
||||||
fn from_row(row: Self::Row) -> Self {
|
fn from_row(row: Self::Row) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -398,6 +398,7 @@ impl Report {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(DatabaseError::QueryError)?;
|
.map_err(DatabaseError::QueryError)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ impl<T: 'static + Send + Sync + Debug> Bot<T> {
|
|||||||
on_server_delete_handlers: Vec::new(),
|
on_server_delete_handlers: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message_command(mut self, command: impl MessageCommand<T> + 'static) -> Self {
|
pub fn message_command(mut self, command: impl MessageCommand<T> + 'static) -> Self {
|
||||||
self.message_commands.push(Arc::new(command));
|
self.message_commands.push(Arc::new(command));
|
||||||
self
|
self
|
||||||
@@ -200,6 +201,7 @@ impl<T: 'static + Send + Sync + Debug> Bot<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut bot = self;
|
let mut bot = self;
|
||||||
|
|
||||||
bot.on_interaction_handlers.insert(
|
bot.on_interaction_handlers.insert(
|
||||||
0,
|
0,
|
||||||
Arc::new(MessageCommandRunner {
|
Arc::new(MessageCommandRunner {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use twilight_model::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::framework::{
|
use crate::framework::{
|
||||||
|
interactions::messages::InteractionResponder,
|
||||||
commands::messages::OriginalMessageUpdater, interactions::InteractionError, runtime::Runtime,
|
commands::messages::OriginalMessageUpdater, interactions::InteractionError, runtime::Runtime,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,8 +19,8 @@ pub struct InteractionContext<T> {
|
|||||||
impl<T> InteractionContext<T> {
|
impl<T> InteractionContext<T> {
|
||||||
pub fn send(
|
pub fn send(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
) -> crate::framework::interactions::messages::InteractionResponder<T> {
|
) -> InteractionResponder<T> {
|
||||||
crate::framework::interactions::messages::InteractionResponder::new(self.clone())
|
InteractionResponder::new(self.clone())
|
||||||
}
|
}
|
||||||
pub fn new(event: InteractionCreate, rt: Arc<Runtime<T>>, prefix: String) -> Self {
|
pub fn new(event: InteractionCreate, rt: Arc<Runtime<T>>, prefix: String) -> Self {
|
||||||
Self { event, rt, prefix }
|
Self { event, rt, prefix }
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ use twilight_model::gateway::payload::incoming::InteractionCreate;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait MessageCommand<T>: Send + Sync + Debug {
|
pub trait MessageCommand<T>: Send + Sync + Debug {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
|
|
||||||
fn description(&self) -> &'static str {
|
fn description(&self) -> &'static str {
|
||||||
"A Payphone context menu command."
|
"A Payphone context menu command."
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn execute(
|
async fn execute(
|
||||||
&self,
|
&self,
|
||||||
ctx: InteractionContext<T>,
|
ctx: InteractionContext<T>,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::framework::interactions::InteractionError::InteractionTypeUnsent;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use twilight_model::gateway::payload::incoming::InteractionCreate;
|
use twilight_model::gateway::payload::incoming::InteractionCreate;
|
||||||
@@ -20,10 +21,7 @@ impl<T: Send + Sync + std::fmt::Debug + 'static> OnInteractionHandler<T>
|
|||||||
async fn on_interaction(&self, event: &InteractionCreate, rt: Arc<Runtime<T>>) -> EventResult {
|
async fn on_interaction(&self, event: &InteractionCreate, rt: Arc<Runtime<T>>) -> EventResult {
|
||||||
if let Err(e) = self.registry.execute(event, rt).await {
|
if let Err(e) = self.registry.execute(event, rt).await {
|
||||||
// Only log errors that aren't "not a message command"
|
// Only log errors that aren't "not a message command"
|
||||||
if !matches!(
|
if !matches!(e, InteractionTypeUnsent) {
|
||||||
e,
|
|
||||||
crate::framework::interactions::InteractionError::InteractionTypeUnsent
|
|
||||||
) {
|
|
||||||
log::error!("Message command dispatch error: {e:?}");
|
log::error!("Message command dispatch error: {e:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ impl<T> InteractionResponder<T> {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| InteractionError::DeferringFailed)?;
|
.map_err(|_| InteractionError::RespondingFailed)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ pub enum InteractionError {
|
|||||||
#[error("The original message was attempted to be edited, but it failed")]
|
#[error("The original message was attempted to be edited, but it failed")]
|
||||||
OriginalMessageEditingFailed,
|
OriginalMessageEditingFailed,
|
||||||
|
|
||||||
|
#[error("Responding to the interaction failed")]
|
||||||
|
RespondingFailed,
|
||||||
|
|
||||||
#[error("No prefixes were returned for the event")]
|
#[error("No prefixes were returned for the event")]
|
||||||
PrefixesVectorEmpty,
|
PrefixesVectorEmpty,
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use crate::{
|
|||||||
state::State,
|
state::State,
|
||||||
utils::{Bye, get_random_u64},
|
utils::{Bye, get_random_u64},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ReportMessageCommand;
|
pub struct ReportMessageCommand;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,9 +107,9 @@ use std::{
|
|||||||
sync::mpsc,
|
sync::mpsc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::groups::calls::commands::ReportMessageCommand;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{Args, Commands},
|
cli::{Args, Commands},
|
||||||
|
groups::calls::commands::ReportMessageCommand,
|
||||||
framework::bot::Bot,
|
framework::bot::Bot,
|
||||||
groups::{
|
groups::{
|
||||||
about::{commands::HelpCommand, components::HelpGoBackButton},
|
about::{commands::HelpCommand, components::HelpGoBackButton},
|
||||||
|
|||||||
Reference in New Issue
Block a user