3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-14 05:57:18 +00:00

Make createChunkedMessage allowedMentions more customizable

This commit is contained in:
Dark 2021-01-18 04:55:10 +01:00
parent 5a8b308934
commit ca2ac12c1e
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
2 changed files with 5 additions and 4 deletions

View file

@ -112,14 +112,14 @@ export async function log(pluginData: GuildPluginData<LogsPluginType>, type: Log
setTimeout(async () => { setTimeout(async () => {
const batchedMessage = pluginData.state.batches.get(channel.id)!.join("\n"); const batchedMessage = pluginData.state.batches.get(channel.id)!.join("\n");
pluginData.state.batches.delete(channel.id); pluginData.state.batches.delete(channel.id);
createChunkedMessage(channel, batchedMessage, cfg.allow_user_mentions).catch(noop); createChunkedMessage(channel, batchedMessage, { users: cfg.allow_user_mentions }).catch(noop);
}, batchTime); }, batchTime);
} }
pluginData.state.batches.get(channel.id)!.push(message); pluginData.state.batches.get(channel.id)!.push(message);
} else { } else {
// If we're not batching log messages, just send them immediately // If we're not batching log messages, just send them immediately
await createChunkedMessage(channel, message, cfg.allow_user_mentions).catch(noop); await createChunkedMessage(channel, message, { users: cfg.allow_user_mentions }).catch(noop);
} }
} }
} }

View file

@ -1,4 +1,5 @@
import { import {
AllowedMentions,
Attachment, Attachment,
Client, Client,
Constants, Constants,
@ -751,11 +752,11 @@ export function chunkMessageLines(str: string, maxChunkLength = 1990): string[]
export async function createChunkedMessage( export async function createChunkedMessage(
channel: TextableChannel, channel: TextableChannel,
messageText: string, messageText: string,
allowUserPings: boolean = true, allowedMentions?: AllowedMentions,
) { ) {
const chunks = chunkMessageLines(messageText); const chunks = chunkMessageLines(messageText);
for (const chunk of chunks) { for (const chunk of chunks) {
await channel.createMessage({ content: chunk, allowedMentions: { users: allowUserPings } }); await channel.createMessage({ content: chunk, allowedMentions });
} }
} }