3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-13 21: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 () => {
const batchedMessage = pluginData.state.batches.get(channel.id)!.join("\n");
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);
}
pluginData.state.batches.get(channel.id)!.push(message);
} else {
// 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 {
AllowedMentions,
Attachment,
Client,
Constants,
@ -751,11 +752,11 @@ export function chunkMessageLines(str: string, maxChunkLength = 1990): string[]
export async function createChunkedMessage(
channel: TextableChannel,
messageText: string,
allowUserPings: boolean = true,
allowedMentions?: AllowedMentions,
) {
const chunks = chunkMessageLines(messageText);
for (const chunk of chunks) {
await channel.createMessage({ content: chunk, allowedMentions: { users: allowUserPings } });
await channel.createMessage({ content: chunk, allowedMentions });
}
}