@@ -48,9 +48,19 @@ process
4848 console . error ( err , 'Uncaught Exception caught' ) ;
4949 } ) ;
5050
51- const { Client, Intents, Constants } = require ( 'discord.js' ) ;
52- const client = new Client ( { intents : [ Intents . FLAGS . GUILDS , Intents . FLAGS . GUILD_MESSAGES , Intents . FLAGS . GUILD_EMOJIS_AND_STICKERS , Intents . FLAGS . DIRECT_MESSAGES ] , partials : [ "CHANNEL" ] } ) ;
53- const { token, botPerms, devGuildId } = require ( './config.json' ) ;
51+ const { Client, GatewayIntentBits, PermissionsBitField, Partials } = require ( 'discord.js' ) ;
52+ const client = new Client ( {
53+ intents : [
54+ GatewayIntentBits . Guilds ,
55+ GatewayIntentBits . GuildMessages ,
56+ GatewayIntentBits . GuildEmojisAndStickers ,
57+ GatewayIntentBits . DirectMessages
58+ ] ,
59+ partials : [
60+ Partials . Channel
61+ ]
62+ } ) ;
63+ const { token, devGuildId, clearCommandList } = require ( './config.json' ) ;
5464
5565var { activityResetTimeout_SECONDS } = require ( './config.json' ) ;
5666activityResetTimeout_SECONDS *= 1000 ;
@@ -97,7 +107,9 @@ const __ = (string, lang, options = undefined) => {
97107
98108// Setup bot ready callback
99109client . once ( 'ready' , async ( ) => {
100- console . log ( gradient . rainbow ( `[+] Logged in as ${ client . user . tag } ! \( ̄▽ ̄)/` ) ) ; // Console log for verbosity
110+ if ( ! clearCommandList == true ) {
111+ console . log ( gradient . rainbow ( `[+] Logged in as ${ client . user . tag } ! \( ̄▽ ̄)/` ) ) ; // Console log for verbosity
112+ }
101113 client . user . setActivity (
102114 "chat for suicide." , {
103115 type : 'LISTENING'
@@ -114,11 +126,25 @@ client.once('ready', async () => {
114126 // Get dev guild ID for slash commands, comment to use global slash commands
115127 const devGuild = client . guilds . cache . get ( devGuildId ) ;
116128 if ( typeof devGuild == "undefined" ) {
117- client . application . commands . set ( commands ) ;
118- console . log ( gradient . rainbow ( "[+] Set global commands" ) ) ;
129+ if ( clearCommandList == true ) {
130+ await client . application . commands . set ( [ ] ) ;
131+ await devGuild . commands . set ( [ ] ) ;
132+ console . log ( gradient . rainbow ( "[+] Cleared commands (helps remove old commands or duplicates)" ) ) ;
133+ console . log ( "\x1B[31mPlease set \"clearCommandList\" in config.json to false to run the bot normally!\x1b[37m" ) ;
134+ } else {
135+ await client . application . commands . set ( commands ) ;
136+ console . log ( gradient . rainbow ( "[+] Set global commands" ) ) ;
137+ }
119138 } else {
120- devGuild . commands . set ( commands ) ;
121- console . log ( gradient . rainbow ( "[+] Set guild commands" ) ) ;
139+ if ( clearCommandList == true ) {
140+ await client . application . commands . set ( [ ] ) ;
141+ await devGuild . commands . set ( [ ] ) ;
142+ console . log ( gradient . rainbow ( "[+] Cleared commands (helps remove old commands or duplicates)" ) ) ;
143+ console . log ( "\x1B[31mPlease set \"clearCommandList\" in config.json to false to run the bot normally!\x1b[37m" ) ;
144+ } else {
145+ await devGuild . commands . set ( commands ) ;
146+ console . log ( gradient . rainbow ( "[+] Set guild/local commands" ) ) ;
147+ }
122148 }
123149} ) ;
124150
@@ -128,7 +154,7 @@ client.once('ready', async () => {
128154client . on ( 'messageCreate' , async message => {
129155 lastMessage = message ;
130156
131- if ( message . author . bot || message . channel . type === 'DM' || ! message . channel . permissionsFor ( client . user ) . has ( botPerms ) ) return ; // Verify permissions of user who sent message before continuing.
157+ if ( message . author . bot || message . channel . type === 'DM' || ! message . channel . permissionsFor ( client . user ) . has ( PermissionsBitField . Flags . SendMessages , PermissionsBitField . Flags . EmbedLinks , PermissionsBitField . Flags . ReadMessageHistory ) ) return ; // Verify permissions of user who sent message before continuing.
132158
133159 let lang = "en" ;
134160 const server_language = lang_db . get ( `lang_${ message . guild . id } ` ) ;
@@ -137,7 +163,7 @@ client.on('messageCreate', async message => {
137163 let LCM = message . content . toLowerCase ( ) ; //Lower case message text
138164
139165 // Mention bot will activate alert message without triggers
140- if ( message . mentions . users . first ( ) === client . user )
166+ if ( message . mentions . users . first ( ) === client . user && message . reference == null )
141167 return require ( './events/bot-mentioned' ) ( message , lang , LCM ) ;
142168
143169 //Check to see if you muted the bot (User side only)
@@ -152,7 +178,7 @@ client.on('messageCreate', async message => {
152178
153179
154180/**
155- * Slash Commands && Buttons
181+ * Slash Commands
156182 */
157183client . on ( "interactionCreate" , async ( interaction ) => {
158184 //Slash Commands
@@ -162,71 +188,40 @@ client.on("interactionCreate", async (interaction) => {
162188 if ( typeof server_language === 'string' ) lang = server_language ;
163189
164190 const { commandName, options } = interaction ;
165- switch ( commandName ) {
166- case "dm" :
167- return require ( './commands/dm' ) . default ( interaction , lang ) ;
168- case "ping" :
169- return require ( './commands/ping' ) . default ( interaction , lang ) ;
170- case "status" :
171- return require ( './commands/status' ) . default ( interaction , lang ) ;
172- case "dmmute" :
173- return require ( "./commands/dmmute" ) . default ( interaction , lang ) ;
174- case "invite" :
175- return require ( "./commands/invite" ) . default ( interaction , lang ) ;
176- case "info" :
177- return require ( "./commands/info" ) . default ( interaction , lang ) ;
178- case "help" :
179- return require ( "./commands/help" ) . default ( interaction , lang ) ;
180- case "language" :
181- return require ( "./commands/set" ) . default ( interaction , lang ) ;
182- case "languages" :
183- return require ( "./commands/lang" ) . default ( interaction , lang ) ;
184- case "mute" :
185- return require ( "./commands/mute" ) . default ( interaction , lang ) ;
186- case "blacklist" :
187- return require ( "./commands/blacklist" ) . default ( interaction , lang ) ;
188- case "tos" :
189- return require ( "./commands/tos" ) . default ( interaction , lang ) ;
190- case "privacy" :
191- return require ( "./commands/privacy" ) . default ( interaction , lang ) ;
192- }
193- } else if ( interaction . isButton ( ) ) {
194- //Buttons
191+ return require ( `./commands/${ commandName } ` ) . default ( interaction , lang ) ;
192+ }
193+
194+ //Buttons
195+ if ( interaction . isButton ( ) ) {
195196 if ( interaction . customId . includes ( 'button2' ) ) {
196197 user_mutes_db . set ( `dmmute_${ interaction . user . id } ` , true ) ;
197198 await interaction . reply ( { content : "👍" } ) ;
198199 }
199200 }
200-
201-
202-
203- //Buttons
204-
205201} ) ;
206202
207203client . login ( token ) ; //Client login
208204
209205module . exports = {
210- client : client ,
211- user_mutes_db : user_mutes_db ,
212- blacklist_db : blacklist_db ,
213- triggers_db : triggers_db ,
214- channel_mutes_db : channel_mutes_db ,
215- lang_db : lang_db ,
216- __ : __
206+ client : client ,
207+ user_mutes_db : user_mutes_db ,
208+ blacklist_db : blacklist_db ,
209+ triggers_db : triggers_db ,
210+ channel_mutes_db : channel_mutes_db ,
211+ lang_db : lang_db ,
212+ __ : __
217213} ;
218214
219215/* JOIN US on our Discord: https://discord.gg/YHvfUqVgWS.
220216
221217Bot developers:
222218
223219 Bobrobot1#1408
224- CactusKing101 #2624
225- Killerjet101#7638
220+ CatusKing #2624
221+ Jet#2471
226222 pengu#1111
227223 HAHALOSAH#4627
228224 Parotay | Luke#3210
229- CPlusPatch#9373
230225
231226Message from developers:
232227
0 commit comments