Use messageLink() function for message links everywhere
This commit is contained in:
parent
1778f95453
commit
b379bea9b8
6 changed files with 19 additions and 17 deletions
|
@ -6,10 +6,9 @@ import { PluginData, helpers } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { CaseTypeColors } from "../../../data/CaseTypeColors";
|
import { CaseTypeColors } from "../../../data/CaseTypeColors";
|
||||||
import { resolveCaseId } from "./resolveCaseId";
|
import { resolveCaseId } from "./resolveCaseId";
|
||||||
import { chunkLines, chunkMessageLines, emptyEmbedValue } from "../../../utils";
|
import { chunkLines, chunkMessageLines, emptyEmbedValue, messageLink } from "../../../utils";
|
||||||
import { inGuildTz } from "../../../utils/timezones";
|
import { inGuildTz } from "../../../utils/timezones";
|
||||||
import { getDateFormat } from "../../../utils/dateFormats";
|
import { getDateFormat } from "../../../utils/dateFormats";
|
||||||
import { buildMessageLink } from "../../../utils/buildMessageLink";
|
|
||||||
|
|
||||||
export async function getCaseEmbed(
|
export async function getCaseEmbed(
|
||||||
pluginData: PluginData<CasesPluginType>,
|
pluginData: PluginData<CasesPluginType>,
|
||||||
|
@ -92,7 +91,7 @@ export async function getCaseEmbed(
|
||||||
|
|
||||||
if (theCase.log_message_id) {
|
if (theCase.log_message_id) {
|
||||||
const [channelId, messageId] = theCase.log_message_id.split("-");
|
const [channelId, messageId] = theCase.log_message_id.split("-");
|
||||||
const link = buildMessageLink(pluginData.guild.id, channelId, messageId);
|
const link = messageLink(pluginData.guild.id, channelId, messageId);
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: emptyEmbedValue,
|
name: emptyEmbedValue,
|
||||||
value: `[Go to original case in case log channel](${link})`,
|
value: `[Go to original case in case log channel](${link})`,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { PluginData } from "knub";
|
import { PluginData } from "knub";
|
||||||
import { CasesPluginType } from "../types";
|
import { CasesPluginType } from "../types";
|
||||||
import { disableLinkPreviews } from "../../../utils";
|
import { disableLinkPreviews, messageLink } from "../../../utils";
|
||||||
import { DBDateFormat, getDateFormat } from "../../../utils/dateFormats";
|
import { DBDateFormat, getDateFormat } from "../../../utils/dateFormats";
|
||||||
import { CaseTypes } from "../../../data/CaseTypes";
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
|
@ -37,7 +37,7 @@ export async function getCaseSummary(
|
||||||
let caseTitle = `\`Case #${theCase.case_number}\``;
|
let caseTitle = `\`Case #${theCase.case_number}\``;
|
||||||
if (withLinks && theCase.log_message_id) {
|
if (withLinks && theCase.log_message_id) {
|
||||||
const [channelId, messageId] = theCase.log_message_id.split("-");
|
const [channelId, messageId] = theCase.log_message_id.split("-");
|
||||||
caseTitle = `[${caseTitle}](https://discord.com/channels/${pluginData.guild.id}/${channelId}/${messageId})`;
|
caseTitle = `[${caseTitle}](${messageLink(pluginData.guild.id, channelId, messageId)})`;
|
||||||
} else {
|
} else {
|
||||||
caseTitle = `\`${caseTitle}\``;
|
caseTitle = `\`${caseTitle}\``;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { convertDelayStringToMS } from "src/utils";
|
import { convertDelayStringToMS, messageLink } from "src/utils";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||||
import { remindersCommand } from "../types";
|
import { remindersCommand } from "../types";
|
||||||
|
@ -48,8 +48,7 @@ export const RemindCmd = remindersCommand({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reminderBody =
|
const reminderBody = args.reminder || messageLink(pluginData.guild.id, msg.channel.id, msg.id);
|
||||||
args.reminder || `https://discord.com/channels/${pluginData.guild.id}/${msg.channel.id}/${msg.id}`;
|
|
||||||
await pluginData.state.reminders.add(
|
await pluginData.state.reminders.add(
|
||||||
msg.author.id,
|
msg.author.id,
|
||||||
msg.channel.id,
|
msg.channel.id,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { UtilityPluginType } from "../types";
|
||||||
import { Constants, EmbedOptions } from "eris";
|
import { Constants, EmbedOptions } from "eris";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
import { chunkMessageLines, preEmbedPadding, trimEmptyLines, trimLines } from "../../../utils";
|
import { chunkMessageLines, messageLink, preEmbedPadding, trimEmptyLines, trimLines } from "../../../utils";
|
||||||
import { getDefaultPrefix } from "knub/dist/commands/commandUtils";
|
import { getDefaultPrefix } from "knub/dist/commands/commandUtils";
|
||||||
import { inGuildTz } from "../../../utils/timezones";
|
import { inGuildTz } from "../../../utils/timezones";
|
||||||
import { getDateFormat } from "../../../utils/dateFormats";
|
import { getDateFormat } from "../../../utils/dateFormats";
|
||||||
|
@ -69,9 +69,7 @@ export async function getMessageInfoEmbed(
|
||||||
Created: **${messageAge} ago** (\`${prettyCreatedAt}\`)
|
Created: **${messageAge} ago** (\`${prettyCreatedAt}\`)
|
||||||
${editedAt ? `Edited at: **${editAge} ago** (\`${prettyEditedAt}\`)` : ""}
|
${editedAt ? `Edited at: **${editAge} ago** (\`${prettyEditedAt}\`)` : ""}
|
||||||
Type: **${type}**
|
Type: **${type}**
|
||||||
Link: [**Go to message ➔**](https://discord.com/channels/${pluginData.guild.id}/${message.channel.id}/${
|
Link: [**Go to message ➔**](${messageLink(pluginData.guild.id, message.channel.id, message.id)})
|
||||||
message.id
|
|
||||||
})
|
|
||||||
`),
|
`),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
import { Message, GuildTextableChannel, EmbedOptions } from "eris";
|
import { Message, GuildTextableChannel, EmbedOptions } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { PluginData } from "knub";
|
||||||
import { UtilityPluginType } from "../types";
|
import { UtilityPluginType } from "../types";
|
||||||
import { UnknownUser, trimLines, embedPadding, resolveMember, resolveUser, preEmbedPadding, sorter } from "src/utils";
|
import {
|
||||||
|
UnknownUser,
|
||||||
|
trimLines,
|
||||||
|
embedPadding,
|
||||||
|
resolveMember,
|
||||||
|
resolveUser,
|
||||||
|
preEmbedPadding,
|
||||||
|
sorter,
|
||||||
|
messageLink,
|
||||||
|
} from "src/utils";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { CaseTypes } from "src/data/CaseTypes";
|
import { CaseTypes } from "src/data/CaseTypes";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
|
@ -123,7 +132,7 @@ export async function getUserInfoEmbed(
|
||||||
|
|
||||||
if (c.log_message_id) {
|
if (c.log_message_id) {
|
||||||
const [channelId, messageId] = c.log_message_id.split("-");
|
const [channelId, messageId] = c.log_message_id.split("-");
|
||||||
return `[${summaryText}](https://discord.com/channels/${pluginData.guild.id}/${channelId}/${messageId})`;
|
return `[${summaryText}](${messageLink(pluginData.guild.id, channelId, messageId)})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return summaryText;
|
return summaryText;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export function buildMessageLink(guildId: string, channelId: string, messageId: string) {
|
|
||||||
return `https://discord.com/channels/${guildId}/${channelId}/${messageId}`;
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue