use embeds for mod logs
This commit is contained in:
parent
8e538df1d8
commit
0fe7496e90
4 changed files with 15 additions and 43 deletions
|
@ -42,9 +42,6 @@ client.on('packet', async (packet) => {
|
|||
discord: {
|
||||
description: `Author: @${m?.author?.username || m?.author_id || "Unknown"} | Channel: ${channel?.name || channel?._id}`
|
||||
},
|
||||
revoltRvembed: {
|
||||
description: `Author: @${m?.author?.username || m?.author_id || "Unknown"} | Channel: ${channel?.name || channel?._id}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,9 +85,6 @@ client.on('packet', async (packet) => {
|
|||
discord: {
|
||||
description: `Author: @${message.author?.username || message.author_id} | Channel: ${message.channel?.name || message.channel_id}`
|
||||
},
|
||||
revoltRvembed: {
|
||||
description: `Author: @${message.author?.username || message.author_id} | Channel: ${message.channel?.name || message.channel_id}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,15 +126,7 @@ async function logModAction(type: 'warn'|'kick'|'ban'|'votekick', server: Server
|
|||
+ `**Warn ID**: \`${infractionID}\`\n`
|
||||
+ (extraText ?? ''),
|
||||
color: embedColor,
|
||||
overrides: {
|
||||
revoltRvembed: {
|
||||
description: `@${mod.user?.username} ${aType} `
|
||||
+ `${await fetchUsername(target)}${type == 'warn' ? '.' : ` from ${server.name}.`}\n`
|
||||
+ `Reason: ${reason ? reason : 'No reason provided.'}\n`
|
||||
+ `Warn ID: ${infractionID}\n`
|
||||
+ (extraText ?? ''),
|
||||
}
|
||||
}
|
||||
overrides: {},
|
||||
});
|
||||
}
|
||||
} catch(e) {
|
||||
|
|
|
@ -218,36 +218,23 @@ async function sendLogMessage(config: LogConfig, content: LogMessage) {
|
|||
const channel = client.channels.get(config.revolt.channel) || await client.channels.fetch(config.revolt.channel);
|
||||
|
||||
let message = '';
|
||||
let embed: SendableEmbed|undefined = undefined;
|
||||
switch(config.revolt.type) {
|
||||
case 'RVEMBED':
|
||||
case 'DYNAMIC':
|
||||
c = { ...c, ...content.overrides?.revoltRvembed };
|
||||
let url = `https://rvembed.janderedev.xyz/embed`;
|
||||
let args = [];
|
||||
case 'EMBED':
|
||||
c = { ...c, ...content.overrides?.revoltEmbed };
|
||||
embed = {
|
||||
title: c.title,
|
||||
description: c.description,
|
||||
colour: c.color,
|
||||
}
|
||||
|
||||
let description = (c.description ?? '');
|
||||
if (c.fields?.length) {
|
||||
for (const field of c.fields) {
|
||||
description += `\n${field.title}\n` +
|
||||
`${field.content}`;
|
||||
embed.description += `\n#### ${field.title}\n${field.content}`;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
description = description.trim();
|
||||
|
||||
if (c.title) args.push(`title=${encodeURIComponent(c.title)}`);
|
||||
if (description) args.push(`description=${encodeURIComponent(description)}`);
|
||||
if (c.color) args.push(`color=${encodeURIComponent(c.color)}`);
|
||||
if (c.image) {
|
||||
args.push(`image=${encodeURIComponent(c.image.url)}`);
|
||||
args.push(`image_large=true`);
|
||||
}
|
||||
|
||||
if (!(config.revolt.type == 'DYNAMIC' && (description.length > 1000 || description.split('\n').length > 6))) {
|
||||
for (const i in args) url += `${i == '0' ? '?' : '&'}${args[i]}`;
|
||||
message = `[\u200b](${url})`;
|
||||
break;
|
||||
}
|
||||
default: // QUOTEBLOCK, PLAIN or unspecified
|
||||
|
||||
// please disregard this mess
|
||||
|
@ -271,6 +258,7 @@ async function sendLogMessage(config: LogConfig, content: LogMessage) {
|
|||
|
||||
channel.sendMessage({
|
||||
content: message,
|
||||
embeds: embed ? [ embed ] : undefined,
|
||||
attachments: content.attachments ?
|
||||
await Promise.all(content.attachments?.map(a => uploadFile(a.content, a.name))) :
|
||||
undefined
|
||||
|
|
|
@ -2,11 +2,9 @@ export default class LogConfig {
|
|||
revolt?: {
|
||||
channel?: string,
|
||||
|
||||
// RVEMBED uses https://rvembed.janderedev.xyz to send a discord style embed, which doesn't
|
||||
// work properly with longer messages.
|
||||
// EMBED uses Revolt's embeds.
|
||||
// PLAIN is like QUOTEBLOCK but without the quotes.
|
||||
// DYNAMIC uses RVEMBED if the message is short enough, otherwise defaults to QUOTEBLOCK.
|
||||
type?: 'QUOTEBLOCK'|'PLAIN'|'RVEMBED'|'DYNAMIC';
|
||||
type?: 'EMBED'|'QUOTEBLOCK'|'PLAIN';
|
||||
}
|
||||
discord?: {
|
||||
webhookUrl?: string,
|
||||
|
|
|
@ -11,7 +11,7 @@ export default class LogMessage {
|
|||
attachments?: { name: string, content: Buffer }[];
|
||||
overrides?: {
|
||||
// These take priority over `revolt`
|
||||
revoltRvembed?: Override,
|
||||
revoltEmbed?: Override,
|
||||
revoltQuoteblock?: Override,
|
||||
|
||||
revolt?: Override,
|
||||
|
|
Loading…
Reference in a new issue