mirror of
https://github.com/insomniafi/insomniaid-bot.git
synced 2024-11-23 07:51:31 +00:00
Add logger function
This commit is contained in:
parent
cf93a9abf8
commit
b6d07eb911
5
src/functions/logger.ts
Normal file
5
src/functions/logger.ts
Normal file
@ -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');
|
||||||
|
}
|
40
src/index.ts
40
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('InsID-Bot ' + process.env.npm_package_version);
|
||||||
console.log('Verkkopeliyhdistys Insomnia ry - Identity Bot');
|
console.log('Verkkopeliyhdistys Insomnia ry - Identity Bot');
|
||||||
console.log('(c)2024 Verkkopeliyhdistys Insomnia ry & Warén Group');
|
console.log('(c)2024 Verkkopeliyhdistys Insomnia ry & Warén Group');
|
||||||
console.log('');
|
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.on('SIGINT', () => {
|
||||||
process.exit();
|
process.exit();
|
||||||
|
Loading…
Reference in New Issue
Block a user