Add flags regex and appeals to descriptions
This commit is contained in:
@@ -2,7 +2,7 @@ import { Message as DiscordMessage, GuildBasedChannel, GuildTextBasedChannel, Om
|
|||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { Database } from '../shared/Database';
|
import { Database } from '../shared/Database';
|
||||||
import { E621Post } from '../types';
|
import { E621Post } from '../types';
|
||||||
import { ALLOWED_MIMETYPES, appealIDRegex, artistIDRegex, blipIDRegex, calculateMD5FromURL, channelIgnoresLinks, channelIsInStaffCategory, channelIsSafe, commentIDRegex, forumTopicIDRegex, getE621Post, getE621PostByMd5, getPostUrl, isEdited, isInSpoilerTags, issueRegex, logDeletion, logEdit, poolIDRegex, PostAction, postIDRegex, prRegex, recordIDRegex, searchLinkRegex, setIDRegex, spoilerOrBlacklist, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from '../utils';
|
import { ALLOWED_MIMETYPES, appealIDRegex, artistIDRegex, blipIDRegex, calculateMD5FromURL, channelIgnoresLinks, channelIsInStaffCategory, channelIsSafe, commentIDRegex, flagIDRegex, forumTopicIDRegex, getE621Post, getE621PostByMd5, getPostUrl, isEdited, isInSpoilerTags, issueRegex, logDeletion, logEdit, poolIDRegex, PostAction, postIDRegex, prRegex, recordIDRegex, searchLinkRegex, setIDRegex, spoilerOrBlacklist, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from '../utils';
|
||||||
|
|
||||||
export type Message<InGuild extends boolean = boolean> = OmitPartialGroupDMChannel<DiscordMessage<InGuild>>;
|
export type Message<InGuild extends boolean = boolean> = OmitPartialGroupDMChannel<DiscordMessage<InGuild>>;
|
||||||
export type Partial = OmitPartialGroupDMChannel<PartialMessage>;
|
export type Partial = OmitPartialGroupDMChannel<PartialMessage>;
|
||||||
@@ -38,6 +38,7 @@ const regexTesters = [
|
|||||||
{ runInDev: true, regex: recordIDRegex, handler: idHandler.bind(null, 'user_feedbacks') },
|
{ runInDev: true, regex: recordIDRegex, handler: idHandler.bind(null, 'user_feedbacks') },
|
||||||
{ runInDev: true, regex: ticketIDRegex, handler: idHandler.bind(null, 'tickets') },
|
{ runInDev: true, regex: ticketIDRegex, handler: idHandler.bind(null, 'tickets') },
|
||||||
{ runInDev: true, regex: appealIDRegex, handler: idHandler.bind(null, 'appeals') },
|
{ runInDev: true, regex: appealIDRegex, handler: idHandler.bind(null, 'appeals') },
|
||||||
|
{ runInDev: true, regex: flagIDRegex, handler: idHandler.bind(null, 'flags') },
|
||||||
{ runInDev: true, regex: artistIDRegex, handler: idHandler.bind(null, 'artists') },
|
{ runInDev: true, regex: artistIDRegex, handler: idHandler.bind(null, 'artists') },
|
||||||
{ runInDev: true, regex: wikiLinkRegex, handler: wikiPageHandler },
|
{ runInDev: true, regex: wikiLinkRegex, handler: wikiPageHandler },
|
||||||
{ runInDev: true, regex: searchLinkRegex, handler: searchHandler },
|
{ runInDev: true, regex: searchLinkRegex, handler: searchHandler },
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder } from 'discord.js';
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder } from 'discord.js';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
|
import { Database } from '../shared/Database';
|
||||||
import { Appeal, AppealUpdate } from '../types';
|
import { Appeal, AppealUpdate } from '../types';
|
||||||
import { getAuthor, getColor, getDescription, getFields } from './event-utils';
|
import { getAuthor, getColor, getDescription, getFields } from './event-utils';
|
||||||
import { humanizeCapitalization } from './string-utils';
|
import { humanizeCapitalization } from './string-utils';
|
||||||
import { Database } from '../shared/Database';
|
|
||||||
|
|
||||||
export async function appealUpdateHandler(client: Client, update: string) {
|
export async function appealUpdateHandler(client: Client, update: string) {
|
||||||
const data: AppealUpdate = JSON.parse(update);
|
const data: AppealUpdate = JSON.parse(update);
|
||||||
@@ -30,7 +30,7 @@ async function postAppeal(client: Client, data: AppealUpdate) {
|
|||||||
|
|
||||||
const row = await getButtons(appeal);
|
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);
|
await Database.putAppeal(appeal.id, message.id);
|
||||||
}
|
}
|
||||||
@@ -96,9 +96,9 @@ async function getButtons(appeal: Appeal): Promise<ActionRowBuilder<ButtonBuilde
|
|||||||
primaryButton
|
primaryButton
|
||||||
.setLabel('Open Flag')
|
.setLabel('Open Flag')
|
||||||
.setURL(`${config.E621_BASE_URL}/post_flags/${appeal.target_id}`);
|
.setURL(`${config.E621_BASE_URL}/post_flags/${appeal.target_id}`);
|
||||||
}
|
|
||||||
|
|
||||||
row.addComponents(primaryButton);
|
row.addComponents(primaryButton);
|
||||||
|
}
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { EmbedAuthorOptions, APIEmbedField } from 'discord.js';
|
import { APIEmbedField, EmbedAuthorOptions } from 'discord.js';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { getE621Post, spoilerOrBlacklist, PostAction } from './e621-utils';
|
import { getE621Post, PostAction, spoilerOrBlacklist } from './e621-utils';
|
||||||
import { blipIDRegex, commentIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex';
|
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.
|
// TODO: Condense this and the message event handler regex array.
|
||||||
const linkReplacers = [
|
const linkReplacers = [
|
||||||
@@ -62,6 +62,16 @@ const linkReplacers = [
|
|||||||
replacement: '/tickets/{match}',
|
replacement: '/tickets/{match}',
|
||||||
encodeURI: false
|
encodeURI: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
regex: appealIDRegex,
|
||||||
|
replacement: '/appeals/{match}',
|
||||||
|
encodeURI: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
regex: flagIDRegex,
|
||||||
|
replacement: '/flags/{match}',
|
||||||
|
encodeURI: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
regex: userIDRegex,
|
regex: userIDRegex,
|
||||||
replacement: '/users/{match}',
|
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 recordIDRegex = new RegExp('record #([0-9]+)', 'gi');
|
||||||
export const ticketIDRegex = new RegExp('ticket #([0-9]+)', 'gi');
|
export const ticketIDRegex = new RegExp('ticket #([0-9]+)', 'gi');
|
||||||
export const artistIDRegex = new RegExp('artist #([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');
|
export const appealIDRegex = new RegExp('appeal #([0-9]+)', 'gi');
|
||||||
|
|
||||||
const tagSearchRegex = '(?:[\\S]| )+?';
|
const tagSearchRegex = '(?:[\\S]| )+?';
|
||||||
|
|||||||
Reference in New Issue
Block a user