Only send welcome messages once per user, until plugin reload

This commit is contained in:
Dragory 2020-08-21 03:48:16 +03:00
parent 902be16ae8
commit 1787ec707c
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 9 additions and 0 deletions

View file

@ -30,5 +30,6 @@ export const WelcomeMessagePlugin = zeppelinPlugin<WelcomeMessagePluginType>()("
const { state, guild } = pluginData;
state.logs = new GuildLogs(guild.id);
state.sentWelcomeMessages = new Set();
},
});

View file

@ -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"]),
});

View file

@ -14,6 +14,7 @@ export interface WelcomeMessagePluginType extends BasePluginType {
config: TConfigSchema;
state: {
logs: GuildLogs;
sentWelcomeMessages: Set<string>;
};
}