added working reaction handling without role assignments
This commit is contained in:
@ -1,6 +1,34 @@
|
||||
const {MessageReaction, PartialMessageReaction, User} = require("discord.js")
|
||||
const {Connection} = require("mysql")
|
||||
|
||||
/**
|
||||
reaction programming syntax
|
||||
-----------------------------------------------------------------------------------------------------
|
||||
MessageID:
|
||||
ReactionEmoji:
|
||||
Role = a role mention
|
||||
Restriction:
|
||||
None: this action has no restrictions
|
||||
AddOnly: nonremovable action
|
||||
AddOnce: can only be added oncuechange
|
||||
Temporary: will only be added for a given time
|
||||
StaffOnly: can only be added to staff [not final]
|
||||
PremiumOnly: can only be added to as premium specified users [not final]
|
||||
Duration: the time duration an action stays active if Restriction Temporary is
|
||||
-----------------------------------------------------------------------------------------------------
|
||||
gets moved to a more permanent documentation once syntax is final
|
||||
*/
|
||||
|
||||
// Development dummy data
|
||||
const DevData = {
|
||||
"1049942781579247627": {
|
||||
"👀":{
|
||||
Role: "test",
|
||||
Restriction: "AddOnly"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* handles reactions in both ways
|
||||
* @param {MessageReaction | PartialMessageReaction} reaction the message reaction
|
||||
@ -10,14 +38,15 @@ const {Connection} = require("mysql")
|
||||
*/
|
||||
const HandleReaction = async (reaction, user, database, Action) => {
|
||||
// Handle if reaction is partial and therefor might throw api errors
|
||||
if (reaction.partial()){
|
||||
if (reaction.partial){
|
||||
try{
|
||||
// global values
|
||||
let react = await reaction.fetch()
|
||||
let message = reaction.message
|
||||
|
||||
// Route Actions
|
||||
switch (Action) {
|
||||
case "add":
|
||||
console.log(DevData[message.id][reaction._emoji.name])
|
||||
break;
|
||||
case "remove":
|
||||
break;
|
||||
@ -26,6 +55,8 @@ const HandleReaction = async (reaction, user, database, Action) => {
|
||||
console.log(e)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
console.error("error while checking if reaction was partial")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user