11//Requires
22const modulename = 'DiscordBot' ;
33const Discord = require ( 'discord.js' ) ;
4+
5+ //FIXME: remove when updating to djs12, as well as this from the package.json
6+ const Collection = require ( '@discordjs/collection' ) ;
7+
48const { dir, log, logOk, logWarn, logError } = require ( '../../extras/console' ) ( modulename ) ;
59
610//NOTE: fix for the fact that fxserver (as of 2627) does not have URLSearchParams as part of the global scope
@@ -48,7 +52,7 @@ module.exports = class DiscordBot {
4852 * NOTE: setting them up statically due to webpack requirements
4953 */
5054 setupCommands ( ) {
51- this . commands = new Discord . Collection ( [
55+ this . commands = new Collection ( [
5256 [ 'addwl' , require ( './commands/addwl.js' ) ] ,
5357 [ 'help' , require ( './commands/help.js' ) ] ,
5458 [ 'status' , require ( './commands/status.js' ) ] ,
@@ -69,7 +73,7 @@ module.exports = class DiscordBot {
6973 if (
7074 ! this . config . announceChannel ||
7175 ! this . client ||
72- this . client . ws . status ||
76+ this . client . status ||
7377 ! this . announceChannel
7478 ) {
7579 if ( GlobalData . verbose ) logWarn ( `returning false, not ready yet` , 'sendAnnouncement' ) ;
@@ -96,30 +100,29 @@ module.exports = class DiscordBot {
96100 this . client . on ( 'ready' , async ( ) => {
97101 logOk ( `Started and logged in as '${ this . client . user . tag } '` ) ;
98102 this . client . user . setActivity ( globals . config . serverName , { type : 'WATCHING' } ) ;
99- this . announceChannel = await this . client . channels . resolve ( this . config . announceChannel ) ;
103+ // this.announceChannel = await this.client.channels.resolve(this.config.announceChannel);
104+ this . announceChannel = this . client . channels . find ( x => x . id === this . config . announceChannel ) ;
100105 if ( ! this . announceChannel ) {
101106 logError ( `The announcements channel could not be found. Check the ID: ${ this . config . announceChannel } ` ) ;
107+ } else {
108+ let cmdDescs = [ ] ;
109+ this . commands . forEach ( ( cmd , name ) => {
110+ cmdDescs . push ( `${ this . config . prefix } ${ name } : ${ cmd . description } ` ) ;
111+ } ) ;
112+ const descLines = [
113+ `:rocket: **txAdmin** v${ GlobalData . txAdminVersion } bot started!` ,
114+ `:game_die: **Commands:**` ,
115+ '```' ,
116+ ...cmdDescs ,
117+ '...more commands to come soon 😮' ,
118+ '```' ,
119+ ] ;
120+ const msg = new Discord . RichEmbed ( {
121+ color : 0x4287F5 ,
122+ description : descLines . join ( '\n' )
123+ } ) ;
124+ this . announceChannel . send ( msg ) ;
102125 }
103-
104- //Prepare description
105- let cmdDescs = [ ] ;
106- this . commands . each ( ( cmd , name ) => {
107- cmdDescs . push ( `${ this . config . prefix } ${ name } : ${ cmd . description } ` ) ;
108- } ) ;
109- const descLines = [
110- `:rocket: **txAdmin** v${ GlobalData . txAdminVersion } bot started!` ,
111- `:game_die: **Commands:**` ,
112- '```' ,
113- ...cmdDescs ,
114- '(more commands to come soon...)' ,
115- '```' ,
116- ] ;
117- const msg = new Discord . MessageEmbed ( {
118- color : 0x4287F5 ,
119- description : descLines . join ( '\n' )
120- } ) ;
121-
122- this . sendAnnouncement ( msg ) ;
123126 } ) ;
124127
125128 //Setup remaining event listeners
0 commit comments