1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 08:20:59 -04:00

Attempt to fix regex when updating case

This commit is contained in:
toast-ts 2024-01-31 23:35:18 +11:00
parent 1a09781bcc
commit baa5d9406a

View File

@ -10,7 +10,7 @@ export default class Case {
if (channel && channel.type === Discord.ChannelType.GuildText) {
const messages = await channel.messages.fetch({limit: 3});
messages.forEach(async message=>{
if (message?.embeds[0]?.title.match(new RegExp(`Case #${caseId}`))) {
if (message?.embeds[0]?.title && message?.embeds[0]?.title.match(new RegExp(`Case #${caseId}`))) {
const findIndex = message?.embeds[0].fields.findIndex(x=>x.name === 'Reason');
await message.edit({embeds: [new client.embed(message.embeds[0]).spliceFields(findIndex, 1, {name: 'Reason', value: `\`${reason}\``})]});
}