Add !message
parent
16a3af07ef
commit
d85a2dad5d
|
@ -75,6 +75,13 @@ This is mainly useful when reporting messages to Discord's Trust & Safety team.
|
||||||
### `!id`
|
### `!id`
|
||||||
Prints the user's ID.
|
Prints the user's ID.
|
||||||
|
|
||||||
|
### `!dm_channel_id`
|
||||||
|
Prints the ID of the current DM channel with the user
|
||||||
|
|
||||||
|
### `!message <number>`
|
||||||
|
Shows the DM channel ID, DM message ID, and message link of the specified user reply.
|
||||||
|
`<number>` is the message number shown in brackets before the user reply in the thread.
|
||||||
|
|
||||||
## Anywhere on the inbox server
|
## Anywhere on the inbox server
|
||||||
These commands can be used anywhere on the inbox server, even outside Modmail threads.
|
These commands can be used anywhere on the inbox server, even outside Modmail threads.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const ThreadMessage = require("../data/ThreadMessage");
|
||||||
|
const utils = require("../utils");
|
||||||
|
|
||||||
module.exports = ({ bot, knex, config, commands }) => {
|
module.exports = ({ bot, knex, config, commands }) => {
|
||||||
commands.addInboxThreadCommand("id", [], async (msg, args, thread) => {
|
commands.addInboxThreadCommand("id", [], async (msg, args, thread) => {
|
||||||
thread.postSystemMessage(thread.user_id);
|
thread.postSystemMessage(thread.user_id);
|
||||||
|
@ -7,4 +10,29 @@ module.exports = ({ bot, knex, config, commands }) => {
|
||||||
const dmChannel = await thread.getDMChannel();
|
const dmChannel = await thread.getDMChannel();
|
||||||
thread.postSystemMessage(dmChannel.id);
|
thread.postSystemMessage(dmChannel.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
commands.addInboxThreadCommand("message", "<messageNumber:number>", async (msg, args, thread) => {
|
||||||
|
/** @type {ThreadMessage} */
|
||||||
|
const threadMessage = await thread.findThreadMessageByMessageNumber(args.messageNumber);
|
||||||
|
if (! threadMessage) {
|
||||||
|
thread.postSystemMessage("No message in this thread with that number");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const channelId = threadMessage.dm_channel_id;
|
||||||
|
// In specific rare cases, such as createThreadOnMention, a thread message may originate from a main server
|
||||||
|
const channelIdServer = utils.getMainGuilds().find(g => g.channels.has(channelId));
|
||||||
|
const messageLink = channelIdServer
|
||||||
|
? `https://discord.com/channels/${channelIdServer.id}/${channelId}/${threadMessage.dm_message_id}`
|
||||||
|
: `https://discord.com/channels/@me/${channelId}/${threadMessage.dm_message_id}`;
|
||||||
|
|
||||||
|
const parts = [
|
||||||
|
`Details for message \`[${threadMessage.message_number}]\`:`,
|
||||||
|
`Channel ID: \`${channelId}\``,
|
||||||
|
`Message ID: \`${threadMessage.dm_message_id}\``,
|
||||||
|
`Link: <${messageLink}>`,
|
||||||
|
];
|
||||||
|
|
||||||
|
thread.postSystemMessage(parts.join("\n"));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue