fix: validate number of reactions on message when adding more
This commit is contained in:
@@ -195,6 +195,11 @@ impl Message {
|
|||||||
|
|
||||||
/// Add a reaction to a message
|
/// Add a reaction to a message
|
||||||
pub async fn add_reaction(&self, db: &Database, user: &User, emoji: &str) -> Result<()> {
|
pub async fn add_reaction(&self, db: &Database, user: &User, emoji: &str) -> Result<()> {
|
||||||
|
// Check how many reactions are already on the message
|
||||||
|
if self.reactions.len() >= 20 {
|
||||||
|
return Err(Error::InvalidOperation);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the emoji is whitelisted
|
// Check if the emoji is whitelisted
|
||||||
if !self.interactions.can_use(emoji) {
|
if !self.interactions.can_use(emoji) {
|
||||||
return Err(Error::InvalidOperation);
|
return Err(Error::InvalidOperation);
|
||||||
|
|||||||
Reference in New Issue
Block a user