-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple support message and message caching improvement
- Loading branch information
Showing
7 changed files
with
129 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import { ThreadChannel } from 'discord.js'; | ||
import { event } from 'jellycommands'; | ||
import { MESSAGE_READ, REACTION_ROLE_CHANNEL } from '../config' | ||
import { hasPermission } from '../utils/reactionHandler'; | ||
|
||
export default event({ | ||
name: 'messageReactionAdd', | ||
run: async (_, reaction, user) => { | ||
try { | ||
const result = await hasPermission(reaction, user); | ||
|
||
result.member.roles.add(result.roleId); | ||
// The bot shouldn't react to its own reactions | ||
if (user.bot) | ||
return | ||
// If this is a reaction in the role reaction channel | ||
if (reaction.message.channelId === REACTION_ROLE_CHANNEL) { | ||
const result = await hasPermission(reaction, user); | ||
result.member.roles.add(result.roleId); | ||
} else { | ||
// Otherwise we make a more general guess that if the original message was from the bot | ||
// and it's a MESSAGE_READ emoji reaction, we assume the message should be deleted | ||
if (reaction.message.author.bot && reaction.emoji.name === MESSAGE_READ) { | ||
reaction.message.delete() | ||
} | ||
} | ||
} catch (error) { | ||
console.error(`Issue in reactionAdd: ${error}`); | ||
console.error(`Issue in messageReactionAdd: ${error}`); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import { event } from 'jellycommands'; | ||
import { REACTION_ROLE_CHANNEL } from '../config'; | ||
import { hasPermission } from '../utils/reactionHandler'; | ||
|
||
export default event({ | ||
name: 'messageReactionRemove', | ||
run: async (_, reaction, user) => { | ||
try { | ||
const result = await hasPermission(reaction, user); | ||
|
||
result.member.roles.remove(result.roleId); | ||
// The bot shouldn't react to its own reactions | ||
if (user.bot) | ||
return | ||
// If this is a reaction in the role reaction channel | ||
if (reaction.message.channelId === REACTION_ROLE_CHANNEL) { | ||
const result = await hasPermission(reaction, user); | ||
result.member.roles.remove(result.roleId); | ||
} | ||
} catch (error) { | ||
console.error(`Issue in reactionRemove: ${error}`); | ||
console.error(`Issue in messageReactionRemove: ${error}`); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ export default event({ | |
updateCache(client) | ||
}, 60_000 * 60) // Every 60 minutes | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters