3 |
import { GuildMember, Message, CommandInteraction, MessageEmbed, ContextMenuInteraction, Interaction } from 'discord.js'; |
import { GuildMember, Message, CommandInteraction, MessageEmbed, ContextMenuInteraction, Interaction } from 'discord.js'; |
4 |
import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios'; |
import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios'; |
5 |
|
|
6 |
|
export function splitMessage(message: string, limit: number = 1000, maxIterationCount: number = 100) { |
7 |
|
const splitted: string[] = []; |
8 |
|
let content = message; |
9 |
|
let { length } = content; |
10 |
|
|
11 |
|
if (length >= limit) { |
12 |
|
let i = 0; |
13 |
|
|
14 |
|
while (length !== 0 && content !== '') { |
15 |
|
splitted.push(content.substring(0, limit)); |
16 |
|
content = content.substring(limit); |
17 |
|
length = content.length; |
18 |
|
i++; |
19 |
|
|
20 |
|
if (i >= maxIterationCount) { |
21 |
|
console.log('Break loop'); |
22 |
|
break; |
23 |
|
} |
24 |
|
} |
25 |
|
} |
26 |
|
else { |
27 |
|
splitted.push(message); |
28 |
|
} |
29 |
|
|
30 |
|
return splitted; |
31 |
|
} |
32 |
|
|
33 |
|
export function getHomeGuild(client: DiscordClient) { |
34 |
|
return client.guilds.cache.get(client.config.props.global.id); |
35 |
|
} |
36 |
|
|
37 |
export function shouldNotModerate(client: DiscordClient, member: GuildMember) { |
export function shouldNotModerate(client: DiscordClient, member: GuildMember) { |
38 |
if (!client.config.props[member.guild.id].admin) { |
if (!client.config.props[member.guild.id].admin) { |
39 |
return false; |
return false; |