2020-08-16 17:39:39 -04:00
|
|
|
const ThreadMessage = require("../data/ThreadMessage");
|
|
|
|
const utils = require("../utils");
|
|
|
|
|
2019-08-13 13:34:46 -04:00
|
|
|
module.exports = ({ bot, knex, config, commands }) => {
|
2020-08-12 17:08:37 -04:00
|
|
|
commands.addInboxThreadCommand("id", [], async (msg, args, thread) => {
|
2018-04-21 08:41:03 -04:00
|
|
|
thread.postSystemMessage(thread.user_id);
|
|
|
|
});
|
2020-05-24 18:33:10 -04:00
|
|
|
|
2020-08-12 17:08:37 -04:00
|
|
|
commands.addInboxThreadCommand("dm_channel_id", [], async (msg, args, thread) => {
|
2020-05-24 18:33:10 -04:00
|
|
|
const dmChannel = await thread.getDMChannel();
|
|
|
|
thread.postSystemMessage(dmChannel.id);
|
|
|
|
});
|
2020-08-16 17:39:39 -04:00
|
|
|
|
|
|
|
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 = [
|
2020-08-16 18:58:20 -04:00
|
|
|
`Details for message \`${threadMessage.message_number}\`:`,
|
2020-08-16 17:39:39 -04:00
|
|
|
`Channel ID: \`${channelId}\``,
|
|
|
|
`Message ID: \`${threadMessage.dm_message_id}\``,
|
|
|
|
`Link: <${messageLink}>`,
|
|
|
|
];
|
|
|
|
|
|
|
|
thread.postSystemMessage(parts.join("\n"));
|
|
|
|
});
|
2018-04-21 08:41:03 -04:00
|
|
|
};
|