Only send welcome messages once per user, until plugin reload
This commit is contained in:
parent
902be16ae8
commit
1787ec707c
3 changed files with 9 additions and 0 deletions
|
@ -30,5 +30,6 @@ export const WelcomeMessagePlugin = zeppelinPlugin<WelcomeMessagePluginType>()("
|
|||
const { state, guild } = pluginData;
|
||||
|
||||
state.logs = new GuildLogs(guild.id);
|
||||
state.sentWelcomeMessages = new Set();
|
||||
},
|
||||
});
|
||||
|
|
|
@ -16,6 +16,13 @@ export const SendWelcomeMessageEvt = welcomeEvent({
|
|||
if (!config.message) return;
|
||||
if (!config.send_dm && !config.send_to_channel) return;
|
||||
|
||||
// Only send welcome messages once per user (even if they rejoin) until the plugin is reloaded
|
||||
if (pluginData.state.sentWelcomeMessages.has(member.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
pluginData.state.sentWelcomeMessages.add(member.id);
|
||||
|
||||
const formatted = await renderTemplate(config.message, {
|
||||
member: stripObjectToScalars(member, ["user"]),
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface WelcomeMessagePluginType extends BasePluginType {
|
|||
config: TConfigSchema;
|
||||
state: {
|
||||
logs: GuildLogs;
|
||||
sentWelcomeMessages: Set<string>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue