1 |
import { roleMention } from '@discordjs/builders'; |
import { roleMention } from '@discordjs/builders'; |
2 |
import { BanOptions, CommandInteraction, FileOptions, Guild, GuildBan, GuildMember, Message, MessageEmbed, TextChannel, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, FileOptions, Guild, GuildBan, GuildMember, Message, MessageEmbed, MessageOptions, MessagePayload, TextChannel, User } from 'discord.js'; |
3 |
import ms from 'ms'; |
import ms from 'ms'; |
4 |
import DiscordClient from '../client/Client'; |
import DiscordClient from '../client/Client'; |
5 |
import Punishment from '../models/Punishment'; |
import Punishment from '../models/Punishment'; |
30 |
} |
} |
31 |
} |
} |
32 |
|
|
33 |
|
async send(guild: Guild, messageOptions: MessageOptions | MessagePayload | string) { |
34 |
|
let channelID = this.client.config.props[guild!.id].logging_channel; |
35 |
|
let channel = guild!.channels.cache.find((c: any) => c.id === channelID) as TextChannel; |
36 |
|
|
37 |
|
if (channel) { |
38 |
|
return await channel.send(messageOptions); |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
|
log(guild: Guild, callback: (channel: TextChannel) => any) { |
43 |
|
this.channel(callback, { guild }); |
44 |
|
} |
45 |
|
|
46 |
logEdit(oldMsg: Message, newMsg: Message) { |
logEdit(oldMsg: Message, newMsg: Message) { |
47 |
this.channel(async (channel) => { |
this.channel(async (channel) => { |
48 |
await channel.send({ |
await channel.send({ |
332 |
}, member); |
}, member); |
333 |
} |
} |
334 |
|
|
335 |
logMute(member: GuildMember, reason: string, timeMs: number | null | undefined, d: User) { |
logMute(member: GuildMember, reason: string, timeMs: number | null | undefined, d: User, hard: boolean = true) { |
336 |
this.channel(async (channel) => { |
this.channel(async (channel) => { |
337 |
await channel.send({ |
await channel.send({ |
338 |
embeds: [ |
embeds: [ |
347 |
.addField('Muted by', d.tag) |
.addField('Muted by', d.tag) |
348 |
.addField('Duration Until', typeof timeMs === 'number' ? `${new Date((timeMs / 1000) + Date.now()).toLocaleString()} (${timeProcess(timeMs / 1000)})` : "*No duration set*") |
.addField('Duration Until', typeof timeMs === 'number' ? `${new Date((timeMs / 1000) + Date.now()).toLocaleString()} (${timeProcess(timeMs / 1000)})` : "*No duration set*") |
349 |
.addField('User ID', member.user.id) |
.addField('User ID', member.user.id) |
350 |
|
.addField('Hardmute', hard ? 'Yes' : 'No') |
351 |
.setFooter({ |
.setFooter({ |
352 |
text: "Muted", |
text: "Muted", |
353 |
}) |
}) |