File tree Expand file tree Collapse file tree 9 files changed +67
-26
lines changed Expand file tree Collapse file tree 9 files changed +67
-26
lines changed Original file line number Diff line number Diff line change 1+ // eslint-disable-next-line no-undef
12module . exports = {
23 'env' : {
3- 'browser ' : false ,
4- 'es2021 ' : true
4+ 'node ' : true ,
5+ 'commonjs ' : true ,
56 } ,
67 'extends' : 'eslint:recommended' ,
78 'overrides' : [
9+ {
10+ 'files' : [ 'src/**/*' ] ,
11+ }
812 ] ,
913 'parserOptions' : {
1014 'ecmaVersion' : 'latest' ,
1115 'sourceType' : 'module'
1216 } ,
1317 'rules' : {
14- 'no-console' : 'true' ,
1518 'indent' : [
1619 'error' ,
1720 'tab'
Original file line number Diff line number Diff line change 1+ export default {
2+ name : 'hello' ,
3+ description : 'Hello world.' ,
4+ aliases : [ 'hey' , 'hi' ] ,
5+
6+ async execute ( message ) {
7+ try {
8+ message . reply ( 'Hello World!' ) ;
9+ } catch ( error ) {
10+ console . log ( error ) ;
11+ }
12+ }
13+ } ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ export default {
2+ event : 'messageCreate' ,
3+ async execute ( client , message ) {
4+ let prefix = '!' ; //await getprefix(message.guild.id); // MySQL WIP
5+
6+ if ( message . content . startsWith ( prefix ) ) {
7+ const args = message . content . substring ( prefix . length ) . split ( / + / ) ;
8+ const command = client . commands . find ( cmd => cmd . name == args [ 0 ] || cmd . aliases . includes ( args [ 0 ] ) ) ;
9+ if ( ! command ) return ; //message.reply(`${args[0]} is not a valid command!`); //uncomment if you want that the bot replies when the command is not a valid command!
10+ command . execute ( message , args , client ) ;
11+ } else {
12+ // Here you can add commands that are not have a prefix.
13+ // like when somebody pings the bot.
14+ }
15+ }
16+ } ;
Original file line number Diff line number Diff line change 1+ export default {
2+ event : 'ready' ,
3+ async execute ( client ) {
4+ try {
5+ console . log ( `Logged in as ${ client . user . tag } ` ) ;
6+ } catch ( error ) {
7+ return console . log ( error ) ;
8+ }
9+ }
10+ } ;
Original file line number Diff line number Diff line change 1- import fs from 'fs' ;
1+ import { readdirSync } from 'fs' ;
22
33async function loadCommands ( client ) {
4- const commandFiles = fs . readdirSync ( './src/commands' ) . filter ( file => file . endsWith ( '.js' ) ) ;
4+ const commandFiles = readdirSync ( './src/commands' ) . filter ( file => file . endsWith ( '.js' ) ) ;
55 for ( let i = 0 ; i < commandFiles . length ; i ++ ) {
6- const file = commandFiles [ i ] ;
7- const cmd = await import ( `../commands/${ file } ` ) ;
6+ const cmd = await import ( `../commands/${ commandFiles [ i ] } ` ) ;
87 client . commands . set ( cmd . default . name , cmd . default ) ;
98
109 if ( cmd . default . aliases ) {
Original file line number Diff line number Diff line change 1+ import { readdirSync } from 'fs' ;
2+
13async function loadEvents ( client ) {
2-
4+ const eventFiles = readdirSync ( './src/events' ) . filter ( file => file . endsWith ( '.js' ) ) ;
5+ for ( let i = 0 ; i < eventFiles . length ; i ++ ) {
6+ const event = await import ( `../events/${ eventFiles [ i ] } ` ) ;
7+ client . on ( event . default . event , event . default . execute . bind ( null , client ) ) ;
8+ }
39}
410
5- export default { }
11+ export default { loadEvents } ;
Original file line number Diff line number Diff line change @@ -6,11 +6,21 @@ import eventHandler from './handlers/events.js';
66
77console . clear ( ) ;
88
9- const client = new Discord . Client ( { intents : 3276799 } ) ;
9+ const client = new Discord . Client ( {
10+ intents : 3276799 ,
11+ allowedMentions : {
12+ repliedUser : true
13+ } ,
14+ } ) ;
1015
1116client . commands = new Discord . Collection ( ) ;
1217client . aliases = new Discord . Collection ( ) ;
1318
1419await commandHanderler . loadCommands ( client ) ;
20+ await eventHandler . loadEvents ( client ) ;
21+
22+ process . on ( 'uncaughtException' , function ( err ) {
23+ console . error ( err ) ;
24+ } ) ;
1525
1626client . login ( `${ config . token } ` ) ;
You can’t perform that action at this time.
0 commit comments