mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
35 lines
1.7 KiB
TypeScript
35 lines
1.7 KiB
TypeScript
import * as Discord from 'discord.js'
|
|
|
|
export const DiscordBot = new Discord.Client()
|
|
|
|
const guildID = '653083797763522580'
|
|
|
|
const reportChannelID = '813255797823766568'
|
|
const loggingChannelID = '844006379823955978'
|
|
const statsLoggingChannelID = '653227346962153472'
|
|
const botReviewLogChannelID = '844044961975500840'
|
|
|
|
DiscordBot.on('ready', async () => {
|
|
console.log('I\'m Ready')
|
|
await getMainGuild().members.fetch()
|
|
console.log(`Fetched ${getMainGuild().members.cache.size} Members`)
|
|
})
|
|
|
|
DiscordBot.login(process.env.DISCORD_TOKEN)
|
|
|
|
export const getMainGuild = () => DiscordBot.guilds.cache.get(guildID)
|
|
export const getReportChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(reportChannelID) as Discord.TextChannel
|
|
export const getLoggingChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(loggingChannelID) as Discord.TextChannel
|
|
export const getBotReviewLogChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(botReviewLogChannelID) as Discord.TextChannel
|
|
export const getStatsLoggingChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(statsLoggingChannelID) as Discord.TextChannel
|
|
|
|
export const discordLog = async (type: string, issuerID: string, embed?: Discord.MessageEmbed, attachment?: { content: string, format: string}, content?: string): Promise<void> => {
|
|
getLoggingChannel().send({
|
|
content: `[${type}] <@${issuerID}> (${issuerID})\n${content || ''}`,
|
|
embed: embed && embed.setTitle(type).setTimestamp(new Date()),
|
|
...(attachment && { files: [
|
|
new Discord.MessageAttachment(Buffer.from(attachment.content), `${type.toLowerCase().replace(/\//g, '-')}-${issuerID}-${Date.now()}.${attachment.format}`)
|
|
]
|
|
})
|
|
})
|
|
} |