Add flags regex and appeals to descriptions
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { Database } from '../shared/Database';
|
||||
import { Appeal, AppealUpdate } from '../types';
|
||||
import { getAuthor, getColor, getDescription, getFields } from './event-utils';
|
||||
import { humanizeCapitalization } from './string-utils';
|
||||
import { Database } from '../shared/Database';
|
||||
|
||||
export async function appealUpdateHandler(client: Client, update: string) {
|
||||
const data: AppealUpdate = JSON.parse(update);
|
||||
@@ -30,7 +30,7 @@ async function postAppeal(client: Client, data: AppealUpdate) {
|
||||
|
||||
const row = await getButtons(appeal);
|
||||
|
||||
const message = await channel.send({ embeds: [embed], components: [row] });
|
||||
const message = await channel.send({ embeds: [embed], components: row.components.length > 0 ? [row] : [] });
|
||||
|
||||
await Database.putAppeal(appeal.id, message.id);
|
||||
}
|
||||
@@ -96,9 +96,9 @@ async function getButtons(appeal: Appeal): Promise<ActionRowBuilder<ButtonBuilde
|
||||
primaryButton
|
||||
.setLabel('Open Flag')
|
||||
.setURL(`${config.E621_BASE_URL}/post_flags/${appeal.target_id}`);
|
||||
}
|
||||
|
||||
row.addComponents(primaryButton);
|
||||
row.addComponents(primaryButton);
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EmbedAuthorOptions, APIEmbedField } from 'discord.js';
|
||||
import { APIEmbedField, EmbedAuthorOptions } from 'discord.js';
|
||||
import { config } from '../config';
|
||||
import { getE621Post, spoilerOrBlacklist, PostAction } from './e621-utils';
|
||||
import { blipIDRegex, commentIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex';
|
||||
import { getE621Post, PostAction, spoilerOrBlacklist } from './e621-utils';
|
||||
import { appealIDRegex, blipIDRegex, commentIDRegex, flagIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex';
|
||||
|
||||
// TODO: Condense this and the message event handler regex array.
|
||||
const linkReplacers = [
|
||||
@@ -62,6 +62,16 @@ const linkReplacers = [
|
||||
replacement: '/tickets/{match}',
|
||||
encodeURI: false
|
||||
},
|
||||
{
|
||||
regex: appealIDRegex,
|
||||
replacement: '/appeals/{match}',
|
||||
encodeURI: false
|
||||
},
|
||||
{
|
||||
regex: flagIDRegex,
|
||||
replacement: '/flags/{match}',
|
||||
encodeURI: false
|
||||
},
|
||||
{
|
||||
regex: userIDRegex,
|
||||
replacement: '/users/{match}',
|
||||
|
||||
@@ -9,6 +9,7 @@ export const takedownIDRegex = new RegExp('takedown #([0-9]+)', 'gi');
|
||||
export const recordIDRegex = new RegExp('record #([0-9]+)', 'gi');
|
||||
export const ticketIDRegex = new RegExp('ticket #([0-9]+)', 'gi');
|
||||
export const artistIDRegex = new RegExp('artist #([0-9]+)', 'gi');
|
||||
export const flagIDRegex = new RegExp('flag #([0-9]+)', 'gi');
|
||||
export const appealIDRegex = new RegExp('appeal #([0-9]+)', 'gi');
|
||||
|
||||
const tagSearchRegex = '(?:[\\S]| )+?';
|
||||
|
||||
Reference in New Issue
Block a user