core/utils/DiscordBot.ts
SKINMAKER 8694e9b19a
deps: change discord.js version to v14 (#503)
* deps: update djs to v14

* refactor: use discord.js v14

* fix: presence not showing properly

* fix: revert Ids

* Update pages/api/v2/bots/[id]/index.ts

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* style: apply code style

* feat: customizable intents

* feat: change node version

* feat: change node version

* fix: misused operator

* deps: fix typescript version to 4.6.4

* fix: fix bot url length (#504)

* refactor: add more advertisements (#508)

* feat: add open review deny log and max denies restriction (#510)

* feat: add open review log channel and embed

* chore: do not include submit page

* chore: mention instead of date

* feat: add max denies error

* typo: 더 이상

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* feat: add exceptions to deny count

* fix: invalid embed used

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* fix: invalid guild

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* fix: invalid position

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* fix: proper reason check position

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* feat: sepcific error message

* refactor: change reason embed format

* fix: knex andWhereNot method to whereNotIn method

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* refactor: detact adblock (#509)

* refactor: detact adblock

* perf: implement mobile detection

* deps: update djs to v14

* refactor: use discord.js v14

* fix: presence not showing properly

* fix: revert Ids

* Update pages/api/v2/bots/[id]/index.ts

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>

* style: apply code style

* feat: customizable intents

* feat: change node version

* feat: change node version

* fix: misused operator

* deps: fix typescript version to 4.6.4

* refactor: use discord.js v14

* deps: update discord.js to 14.2.0

* style: split options

* style: prettify

* deps: update erlpack

Co-authored-by: Junseo Park <wonderlandpark@outlook.kr>
Co-authored-by: Byungchul Kim <64084503+chul0721@users.noreply.github.com>
Co-authored-by: Eunwoo Choi <61371424+eunwoo1104@users.noreply.github.com>
2022-08-30 23:28:48 +09:00

42 lines
2.1 KiB
TypeScript

import * as Discord from 'discord.js'
export const DiscordBot = new Discord.Client({
intents: Number(process.env.DISCORD_CLIENT_INTENTS ?? 32767)
})
const guildID = '653083797763522580'
const reportChannelID = '813255797823766568'
const loggingChannelID = '844006379823955978'
const statsLoggingChannelID = '653227346962153472'
const reviewGuildID = '906537041326637086'
const botReviewLogChannelID = '906551334063439902'
const openBotReviewLogChannelID = '1008376563731013643'
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 getReviewGuild = () => DiscordBot.guilds.cache.get(reviewGuildID)
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 => getReviewGuild().channels.cache.get(botReviewLogChannelID) as Discord.TextChannel
export const getStatsLoggingChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(statsLoggingChannelID) as Discord.TextChannel
export const getOpenBotReviewLogChannel = (): Discord.TextChannel => getMainGuild().channels.cache.get(openBotReviewLogChannelID) as Discord.TextChannel
export const discordLog = async (type: string, issuerID: string, embed?: Discord.EmbedBuilder, attachment?: { content: string, format: string}, content?: string): Promise<void> => {
getLoggingChannel().send({
content: `[${type}] <@${issuerID}> (${issuerID})\n${content || ''}`,
embeds: [embed && embed.setTitle(type).setTimestamp(new Date())],
...(attachment && { files: [
new Discord.AttachmentBuilder(Buffer.from(attachment.content), {name: `${type.toLowerCase().replace(/\//g, '-')}-${issuerID}-${Date.now()}.${attachment.format}`
})]})
})
}