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:
parent
5a8b308934
commit
ca2ac12c1e
2 changed files with 5 additions and 4 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue