feat: add member cache; handle all role changes with RoleManagerPlugin; exit gracefully
This commit is contained in:
parent
fd60a09947
commit
fa50110766
48 changed files with 755 additions and 264 deletions
|
@ -1,10 +1,13 @@
|
|||
import { GuildMember } from "discord.js";
|
||||
import { guildPluginEventListener } from "knub";
|
||||
import { SECONDS } from "../../../utils";
|
||||
import { parseCustomId } from "../../../utils/parseCustomId";
|
||||
import { RoleManagerPlugin } from "../../RoleManager/RoleManagerPlugin";
|
||||
import { getAllRolesInButtons } from "../functions/getAllRolesInButtons";
|
||||
import { RoleButtonsPluginType, TRoleButtonOption } from "../types";
|
||||
|
||||
const ROLE_BUTTON_CD = 5 * SECONDS;
|
||||
|
||||
export const onButtonInteraction = guildPluginEventListener<RoleButtonsPluginType>()({
|
||||
event: "interactionCreate",
|
||||
async listener({ pluginData, args }) {
|
||||
|
@ -33,6 +36,16 @@ export const onButtonInteraction = guildPluginEventListener<RoleButtonsPluginTyp
|
|||
return;
|
||||
}
|
||||
|
||||
const cdIdentifier = `${args.interaction.user.id}-${optionIndex}`;
|
||||
if (pluginData.cooldowns.isOnCooldown(cdIdentifier)) {
|
||||
args.interaction.reply({
|
||||
ephemeral: true,
|
||||
content: "Please wait before clicking the button again",
|
||||
});
|
||||
return;
|
||||
}
|
||||
pluginData.cooldowns.setCooldown(cdIdentifier, ROLE_BUTTON_CD);
|
||||
|
||||
const member = args.interaction.member as GuildMember;
|
||||
const role = pluginData.guild.roles.cache.get(option.role_id);
|
||||
const roleName = role?.name || option.role_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue