@@ -16,25 +16,17 @@ module.exports = async (client, message) => {
16
16
if ( message . author . bot ) return ;
17
17
if ( message . webhookId ) return ;
18
18
19
- // Grab the settings for this server from Enmap.
20
- // If there is no guild, get default conf (DMs)
21
- const settings = config . defaultSettings ;
19
+
22
20
23
21
// Checks if the bot was mentioned via regex, with no message after it,
24
22
// returns the prefix. The reason why we used regex here instead of
25
23
// message.mentions is because of the mention prefix later on in the
26
24
// code, would render it useless.
27
25
const prefixMention = new RegExp ( `^<@!?${ client . user . id } > ?$` ) ;
28
26
if ( message . content . match ( prefixMention ) ) {
29
- return message . reply ( `My prefix on this guild is \` ${ settings . prefix } \` ` ) ;
27
+ return message . reply ( `This bot's commands can be used by slash commands ` ) ;
30
28
}
31
29
32
- // It's also good practice to ignore any and all messages that do not start
33
- // with our prefix, or a bot mention.
34
- const prefix = new RegExp ( `^<@!?${ client . user . id } > |^\\${ settings . prefix } ` ) . exec ( message . content ) ;
35
- // If it's not a command, treat it as a relay if it matches our relay channel.
36
- if ( ! prefix ) {
37
- // If it is a relay channel for Main
38
30
39
31
config . relays . forEach ( async ( value , key ) => {
40
32
if ( value === message . channel . id ) {
@@ -50,66 +42,4 @@ module.exports = async (client, message) => {
50
42
}
51
43
52
44
} )
53
-
54
-
55
-
56
-
57
-
58
- } else {
59
- // Here we separate our "command" name, and our "arguments" for the command.
60
- // e.g. if we have the message "+say Is this the real life?" , we'll get the following:
61
- // command = say
62
- // args = ["Is", "this", "the", "real", "life?"]
63
- const args = message . content . slice ( prefix [ 0 ] . length ) . trim ( ) . split ( / + / g) ;
64
- const command = args . shift ( ) . toLowerCase ( ) ;
65
-
66
- // If the member on a guild is invisible or not cached, fetch them.
67
- if ( message . guild && ! message . member ) await message . guild . members . fetch ( message . author ) ;
68
-
69
- // Get the user or member's permission level from the elevation
70
- const level = permlevel ( message ) ;
71
-
72
- // Check whether the command, or alias, exist in the collections defined
73
- // in app.js.
74
- const cmd = container . commands . get ( command ) || container . commands . get ( container . aliases . get ( command ) ) ;
75
- // using this const varName = thing OR otherThing; is a pretty efficient
76
- // and clean way to grab one of 2 values!
77
- if ( ! cmd ) return ;
78
-
79
- // Some commands may not be useable in DMs. This check prevents those commands from running
80
- // and return a friendly error message.
81
- if ( cmd && ! message . guild && cmd . conf . guildOnly )
82
- return message . channel . send ( "This command is unavailable via private message. Please run this command in a guild." ) ;
83
-
84
- if ( ! cmd . conf . enabled ) return ;
85
-
86
- if ( level < container . levelCache [ cmd . conf . permLevel ] ) {
87
- if ( settings . systemNotice === "true" ) {
88
- return message . channel . send ( `You do not have permission to use this command.
89
- Your permission level is ${ level } (${ config . permLevels . find ( l => l . level === level ) . name } )
90
- This command requires level ${ container . levelCache [ cmd . conf . permLevel ] } (${ cmd . conf . permLevel } )` ) ;
91
- } else {
92
- return ;
93
- }
94
- }
95
-
96
- // To simplify message arguments, the author's level is now put on level (not member so it is supported in DMs)
97
- // The "level" command module argument will be deprecated in the future.
98
- message . author . permLevel = level ;
99
-
100
- message . flags = [ ] ;
101
- while ( args [ 0 ] && args [ 0 ] [ 0 ] === "-" ) {
102
- message . flags . push ( args . shift ( ) . slice ( 1 ) ) ;
103
- }
104
- // If the command exists, **AND** the user has permission, run it.
105
- try {
106
- await cmd . run ( client , message , args , level ) ;
107
- logger . log ( `${ config . permLevels . find ( l => l . level === level ) . name } ${ message . author . id } ran command ${ cmd . help . name } ` , "cmd" ) ;
108
- } catch ( e ) {
109
- console . error ( e ) ;
110
- message . channel . send ( { content : `There was a problem with your request.\n\`\`\`${ e . message } \`\`\`` } )
111
- . catch ( e => console . error ( "An error occurred replying on an error" , e ) ) ;
112
- }
113
-
114
- }
115
45
} ;
0 commit comments