Add anti-raid levels to automod. Large refactor of spam detection. Add member_join and member_join_spam triggers.
Anti-raid levels don't by themselves do anything, but they can be used in overrides to activate specific automod items. Spam detection should now be more reliable and also combine further spam messages after the initial detection into the archive. Messages deleted by automod no longer create the normal deletion log entry. Instead, the AUTOMOD_ACTION log entry contains the deleted message or an archive if there are multiple (i.e. spam).
This commit is contained in:
parent
dc27821a63
commit
84135b201b
14 changed files with 1179 additions and 550 deletions
|
@ -71,10 +71,7 @@ export class GuildArchives extends BaseGuildRepository {
|
|||
return result.identifiers[0].id;
|
||||
}
|
||||
|
||||
async createFromSavedMessages(savedMessages: SavedMessage[], guild: Guild, expiresAt = null) {
|
||||
if (expiresAt == null) expiresAt = moment().add(DEFAULT_EXPIRY_DAYS, "days");
|
||||
|
||||
const headerStr = await renderTemplate(MESSAGE_ARCHIVE_HEADER_FORMAT, { guild });
|
||||
protected async renderLinesFromSavedMessages(savedMessages: SavedMessage[], guild: Guild) {
|
||||
const msgLines = [];
|
||||
for (const msg of savedMessages) {
|
||||
const channel = guild.channels.get(msg.channel_id);
|
||||
|
@ -89,11 +86,29 @@ export class GuildArchives extends BaseGuildRepository {
|
|||
});
|
||||
msgLines.push(line);
|
||||
}
|
||||
return msgLines;
|
||||
}
|
||||
|
||||
async createFromSavedMessages(savedMessages: SavedMessage[], guild: Guild, expiresAt = null) {
|
||||
if (expiresAt == null) expiresAt = moment().add(DEFAULT_EXPIRY_DAYS, "days");
|
||||
|
||||
const headerStr = await renderTemplate(MESSAGE_ARCHIVE_HEADER_FORMAT, { guild });
|
||||
const msgLines = await this.renderLinesFromSavedMessages(savedMessages, guild);
|
||||
const messagesStr = msgLines.join("\n");
|
||||
|
||||
return this.create([headerStr, messagesStr].join("\n\n"), expiresAt);
|
||||
}
|
||||
|
||||
async addSavedMessagesToArchive(archiveId: string, savedMessages: SavedMessage[], guild: Guild) {
|
||||
const msgLines = await this.renderLinesFromSavedMessages(savedMessages, guild);
|
||||
const messagesStr = msgLines.join("\n");
|
||||
|
||||
const archive = await this.find(archiveId);
|
||||
archive.body += "\n" + messagesStr;
|
||||
|
||||
await this.archives.update({ id: archiveId }, { body: archive.body });
|
||||
}
|
||||
|
||||
getUrl(baseUrl, archiveId) {
|
||||
return baseUrl ? `${baseUrl}/archives/${archiveId}` : `Archive ID: ${archiveId}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue