-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a3d1b0
commit 074602c
Showing
7 changed files
with
653 additions
and
1,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { Message} from 'discord.js'; | ||
import { MessageEmbed } from 'discord.js'; | ||
|
||
import { ModMailThread } from '../db/modmail_thread'; | ||
import { getModMailThread } from './getModMailThread'; | ||
|
||
export const handleDmThread = async (msg: Message) => { | ||
const modmailThreadData = await ModMailThread.findOne({ | ||
userId: msg.author.id, | ||
guildId: msg.guildId, | ||
closedAt: { $exists: false }, | ||
}).exec(); | ||
|
||
if(!modmailThreadData) { | ||
return | ||
} | ||
|
||
const modmailThread = await getModMailThread(msg.guild, msg.author) | ||
|
||
if (msg.attachments.size === 0) { | ||
await modmailThread.send({ | ||
embeds: [ | ||
new MessageEmbed() | ||
.setColor(0xff_96_00) | ||
.setAuthor({ | ||
name: `${msg.author.username}#${msg.author.discriminator}`, | ||
iconURL: msg.author.avatarURL(), | ||
}) | ||
.setDescription(msg.content) | ||
.setTitle('Message Received') | ||
.setTimestamp(msg.createdTimestamp), | ||
], | ||
}); | ||
|
||
msg.react("✅") | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Guild, Message, TextChannel } from 'discord.js'; | ||
|
||
import { DM_ALT_CHANNEL_ID } from '../../../env'; | ||
import { DMThread } from '../db/dm_thread'; | ||
import { cache } from "./cache"; | ||
|
||
export const isDmThread = async (msg: Message): Promise<boolean> => { | ||
if(!msg.channel.isThread()) { | ||
return false | ||
} | ||
|
||
if (msg.channel.parent?.id !== DM_ALT_CHANNEL_ID) { | ||
return false | ||
} | ||
|
||
const dmThread = await DMThread.findOne({ | ||
guildId: msg.guild, | ||
threadId: msg.channelId, | ||
channelId: msg.channel.parent.id, | ||
closedAt: { $exists: false } | ||
}).exec() | ||
|
||
return !!dmThread | ||
}; |
Oops, something went wrong.