diff --git a/src/functions/logger.ts b/src/functions/logger.ts new file mode 100644 index 0000000..5279de4 --- /dev/null +++ b/src/functions/logger.ts @@ -0,0 +1,5 @@ +export default function logger(area: string, text?: string){ + let date = new Date(); + console.log('[' + area + '] - ' + date.toISOString()); + if(text) console.log(text + '\n'); +} diff --git a/src/index.ts b/src/index.ts index f9a78ae..c5f6bb5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,47 @@ -import { Client as DiscordClient, Collection, IntentsBitField } from "discord.js"; +import Discord from "discord.js"; +import logger from "./functions/logger" console.log('InsID-Bot ' + process.env.npm_package_version); console.log('Verkkopeliyhdistys Insomnia ry - Identity Bot'); console.log('(c)2024 Verkkopeliyhdistys Insomnia ry & Warén Group'); console.log(''); -console.log('[Bot] Starting'); +logger('Bot', 'Starting'); + +const discordClient = new Discord.Client({ + intents: [ + Discord.GatewayIntentBits.GuildMembers, + Discord.GatewayIntentBits.Guilds + ] +}); + +discordClient.on('ready', () => { + logger('Discord Client', 'Ready'); +}); + +discordClient.on("interactionCreate", (interaction) => { + logger('Discord Client', 'Interaction Create'); +}); + +discordClient.on("guildMemberAdd", (member) => { + logger('Discord Client', 'Guild Member Add'); +}); + +discordClient.on("guildMemberRemove", (member) => { + logger('Discord Client', 'Guild Member Remove'); +}); + +discordClient.on("guildMemberUpdate", (oldMember, newMember) => { + logger('Discord Client', 'Guild Member Update'); +}); + +discordClient.login(process.env.DISCORD_TOKEN) + .then(() => { + logger('Discord Client', 'Login: Successful'); + }) + .catch(err => { + logger('Discord Client', 'Login: Failed'); + }); process.on('SIGINT', () => { process.exit();