1 |
import fs from 'fs'; |
import fs from 'fs'; |
2 |
import DiscordClient from '../client/Client'; |
import DiscordClient from '../client/Client'; |
3 |
import { GuildMember } from 'discord.js'; |
import { GuildMember, Message, CommandInteraction, MessageEmbed } from 'discord.js'; |
4 |
import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios'; |
import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios'; |
5 |
|
|
6 |
export function shouldNotModerate(client: DiscordClient, member: GuildMember) { |
export function shouldNotModerate(client: DiscordClient, member: GuildMember) { |
13 |
return member.roles.cache.has(role); |
return member.roles.cache.has(role); |
14 |
} |
} |
15 |
|
|
16 |
|
export async function hasPermission(client: DiscordClient, member: GuildMember, msg: Message | CommandInteraction, mod: GuildMember | null, error: string = "You don't have permission to moderate this user") { |
17 |
|
let m = mod; |
18 |
|
|
19 |
|
if (!m) { |
20 |
|
m = msg.member! as GuildMember; |
21 |
|
} |
22 |
|
|
23 |
|
if (member.roles.highest?.position > m.roles.highest?.position) { |
24 |
|
await msg.reply({ |
25 |
|
embeds: [ |
26 |
|
new MessageEmbed() |
27 |
|
.setColor('#f14a60') |
28 |
|
.setDescription(`:x: ${error}`) |
29 |
|
] |
30 |
|
}); |
31 |
|
|
32 |
|
return false; |
33 |
|
} |
34 |
|
|
35 |
|
return true; |
36 |
|
} |
37 |
|
|
38 |
export function timeProcess(seconds: number) { |
export function timeProcess(seconds: number) { |
39 |
let interval = seconds / (60 * 60 * 24 * 30 * 365); |
let interval = seconds / (60 * 60 * 24 * 30 * 365); |
40 |
|
|