1 |
import fs from 'fs'; |
import fs from 'fs'; |
2 |
import DiscordClient from '../client/Client'; |
import DiscordClient from '../client/Client'; |
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 } from 'axios'; |
5 |
import { formatDistanceToNowStrict } from 'date-fns'; |
import { formatDistanceToNowStrict, formatDuration, intervalToDuration } from 'date-fns'; |
|
import { Snippet } from '../services/SnippetManager'; |
|
6 |
|
|
7 |
export function parseEmbedsInString(content: string) { |
export function parseEmbedsInString(content: string) { |
8 |
const embedExpressions = content.matchAll(/embed\:(\{[^\n]+\})/g); |
const embedExpressions = content.matchAll(/embed\:(\{[^\n]+\})/g); |
61 |
|
|
62 |
const role = client.config.props[member.guild.id].admin; |
const role = client.config.props[member.guild.id].admin; |
63 |
|
|
64 |
return member.roles.cache.has(role); |
return role && role.trim() !== '' && member.roles.cache.has(role); |
65 |
} |
} |
66 |
|
|
67 |
export async function hasPermission(client: DiscordClient, member: GuildMember, msg: Message | CommandInteraction | ContextMenuInteraction, mod: GuildMember | null, error: string = "You don't have permission to moderate this user") { |
export async function hasPermission(client: DiscordClient, member: GuildMember, msg: Message | CommandInteraction | ContextMenuInteraction, mod: GuildMember | null, error: string = "You don't have permission to moderate this user") { |
99 |
} |
} |
100 |
|
|
101 |
export function timeProcess(seconds: number) { |
export function timeProcess(seconds: number) { |
102 |
return formatDistanceToNowStrict(new Date(seconds)); |
return formatDuration(intervalToDuration({ start: 0, end: seconds * 1000 })); |
103 |
} |
} |
104 |
|
|
105 |
|
|