Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Commit

Permalink
feat: Custom log and error handlers (#142)
Browse files Browse the repository at this point in the history
* perf: restructured files

add src directory and refactor imports

* feat: add custom logger

add a custom loghandler util function

* feat: custom error handler

create a custom error handler with sending error as embbed message functionality

* feat: log and error custom handlers

restructure code ,create custom loggers,add error handling in all modules

* refactor: fix grammatical bugs in code

* fix: resolve typos and remove university leader programme

* Update src/Commands/DSA.js

Co-authored-by: David Leal <halfpacho@gmail.com>

* refactor: fix typos

* fix: minor fix

* fix: minor fixes

* fix: remove extra argument

remove extra agrument value in dsa module

* refactor: minor typos

Co-authored-by: David Leal <halfpacho@gmail.com>
  • Loading branch information
DhansAL and Panquesito7 authored Dec 30, 2021
1 parent 65593a9 commit dcda152
Show file tree
Hide file tree
Showing 27 changed files with 503 additions and 388 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
.env
package-lock.json
38 changes: 0 additions & 38 deletions Commands/DSA.js

This file was deleted.

22 changes: 0 additions & 22 deletions Commands/command.js

This file was deleted.

30 changes: 0 additions & 30 deletions Commands/help.js

This file was deleted.

9 changes: 0 additions & 9 deletions Commands/hey.js

This file was deleted.

54 changes: 0 additions & 54 deletions Commands/links.js

This file was deleted.

18 changes: 0 additions & 18 deletions Commands/meme.js

This file was deleted.

10 changes: 0 additions & 10 deletions Commands/presence.js

This file was deleted.

72 changes: 0 additions & 72 deletions Commands/restrictedWords.js

This file was deleted.

30 changes: 0 additions & 30 deletions Commands/source.js

This file was deleted.

24 changes: 0 additions & 24 deletions Commands/translate.js

This file was deleted.

11 changes: 0 additions & 11 deletions Commands/version.js

This file was deleted.

29 changes: 17 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,40 @@ require('dotenv').config();
client.commands = new Discord.Collection();
//Command inclusion

const presence = require('./Commands/presence.js');
const restrict = require('./Commands/restrictedWords.js');
const presence = require('./src/Commands/presence');
const restrict = require('./src/Commands/restrictedWords');
const { botLogHandler } = require('./src/utils/botLogHandler');

// Up commands

botLogHandler.log('debug', 'setting commands');
const commandFiles = fs
.readdirSync('./Commands/')
.readdirSync('./src/Commands/')
.filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./Commands/${file}`);
const command = require(`./src/Commands/${file}`);

client.commands.set(command.name, command);
}

botLogHandler.log('debug', 'starting bot');
client.on('ready', () => {

console.log(
`Classroom Monitor is currently running on version v${require('./package.json').version
`Classroom Monitor is currently running on version v${
require('./package.json').version
}`
);

//Bot Status
presence(client);

// restricted words
restrict(client, (message) => { });
restrict(client, (message) => {});
});

client.on('message', (message) => {
if (
(!message.content.startsWith(prefix)) || message.author.bot || message.channel.type == 'dm'
!message.content.startsWith(prefix) ||
message.author.bot ||
message.channel.type == 'dm'
)
return;

Expand All @@ -49,10 +52,12 @@ client.on('message', (message) => {
try {
client.commands.get(command).execute(message, args, Discord);
} catch {
message.channel.send("Please use a valid command :slight_smile:\nTo see the list of valid commands use `cm!help`")
message.channel.send(
'Please use a valid command :slight_smile:\nTo see the list of valid commands use `cm!help`'
);
}
});

// Authentications

botLogHandler.log('debug', 'Validating environment variables');
client.login(process.env.BOT_TOKEN);
Loading

0 comments on commit dcda152

Please sign in to comment.