Add GuildArchives.getUrl for getting the archive entry URL
This commit is contained in:
parent
a2b7038b71
commit
429653c66d
3 changed files with 9 additions and 5 deletions
|
@ -90,4 +90,8 @@ export class GuildArchives extends BaseRepository {
|
||||||
|
|
||||||
return this.create([headerStr, messagesStr].join("\n\n"), expiresAt);
|
return this.create([headerStr, messagesStr].join("\n\n"), expiresAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUrl(baseUrl, archiveId) {
|
||||||
|
return baseUrl ? `${baseUrl}/archives/${archiveId}` : `Archive ID: ${archiveId}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,14 +341,14 @@ export class LogsPlugin extends Plugin {
|
||||||
async onMessageDeleteBulk(savedMessages: SavedMessage[]) {
|
async onMessageDeleteBulk(savedMessages: SavedMessage[]) {
|
||||||
const channel = this.guild.channels.get(savedMessages[0].channel_id);
|
const channel = this.guild.channels.get(savedMessages[0].channel_id);
|
||||||
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
|
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
|
||||||
const baseUrl = this.knub.getGlobalConfig().url;
|
const archiveUrl = this.archives.getUrl(this.knub.getGlobalConfig().url, archiveId);
|
||||||
|
|
||||||
this.guildLogs.log(
|
this.guildLogs.log(
|
||||||
LogType.MESSAGE_DELETE_BULK,
|
LogType.MESSAGE_DELETE_BULK,
|
||||||
{
|
{
|
||||||
count: savedMessages.length,
|
count: savedMessages.length,
|
||||||
channel,
|
channel,
|
||||||
archiveUrl: `${baseUrl}/archives/${archiveId}`
|
archiveUrl
|
||||||
},
|
},
|
||||||
savedMessages[0].id
|
savedMessages[0].id
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ const MAX_INTERVAL = 300;
|
||||||
const SPAM_ARCHIVE_EXPIRY_DAYS = 90;
|
const SPAM_ARCHIVE_EXPIRY_DAYS = 90;
|
||||||
|
|
||||||
export class SpamPlugin extends Plugin {
|
export class SpamPlugin extends Plugin {
|
||||||
public static pluginName = 'spam';
|
public static pluginName = "spam";
|
||||||
|
|
||||||
protected actions: GuildActions;
|
protected actions: GuildActions;
|
||||||
protected logs: GuildLogs;
|
protected logs: GuildLogs;
|
||||||
|
@ -163,8 +163,8 @@ export class SpamPlugin extends Plugin {
|
||||||
const expiresAt = moment().add(SPAM_ARCHIVE_EXPIRY_DAYS, "days");
|
const expiresAt = moment().add(SPAM_ARCHIVE_EXPIRY_DAYS, "days");
|
||||||
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild, expiresAt);
|
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild, expiresAt);
|
||||||
|
|
||||||
const url = this.knub.getGlobalConfig().url;
|
const baseUrl = this.knub.getGlobalConfig().url;
|
||||||
return url ? `${url}/archives/${archiveId}` : `Archive ID: ${archiveId}`;
|
return this.archives.getUrl(baseUrl, archiveId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async logAndDetectSpam(
|
async logAndDetectSpam(
|
||||||
|
|
Loading…
Add table
Reference in a new issue