1
1
const Discord = require ( "discord.js" ) ;
2
- const { searchOneDB , getFactorioRoles } = require ( "../../functions" ) ;
2
+ const { getFactorioRoles } = require ( "../../functions" ) ;
3
3
const { LinkingCache } = require ( "../../functions" ) ;
4
4
const { ErrorManager } = require ( "../../utils/error-manager" ) ;
5
5
const lodash = require ( "lodash" ) ;
6
- let { linkConfirmation } = require ( "../../config/messages.json" )
6
+ let { linkConfirmation } = require ( "../../config/messages.json" ) ;
7
+ const { DatabaseConnection } = require ( "../../utils/database-manager" ) ;
7
8
8
9
module . exports = {
9
10
config : {
@@ -28,31 +29,35 @@ module.exports = {
28
29
return message . channel . send ( "Give a Factorio name/Discord ping!" )
29
30
let user ;
30
31
if ( message . mentions . users . first ( ) ) {
31
- let res = await searchOneDB ( "otherData" , "linkedPlayers" , {
32
+ let res = await DatabaseConnection . findOneDB ( "otherData" , "linkedPlayers" , {
32
33
discordID : ( message . mentions . users . first ( ) ) . id ,
33
34
} )
34
- if ( res == undefined )
35
- return message . channel . send ( "User not linked!" ) ;
35
+ if ( res === undefined || res === null ) return message . channel . send ( "User not linked, therefore has no roles!" ) ;
36
36
user = res . factorioName ;
37
37
} else {
38
- user = args [ 0 ] ;
38
+ let res = await DatabaseConnection . findOneDB ( "otherData" , "linkedPlayers" , {
39
+ factorioName : args [ 0 ] ,
40
+ } )
41
+ if ( res === undefined || res === null ) return message . channel . send ( "User not linked, therefore has no roles!" ) ;
42
+ user = res . factorioName ;
39
43
}
40
44
41
45
let rolesEmbed = new Discord . MessageEmbed ( )
42
- . setTitle ( "Roles of a Factorio player" )
43
- . setDescription ( "Roles of a Factorio player" )
44
- . setColor ( "GREEN" )
45
- . setAuthor (
46
- `${ message . guild . me . displayName } Help` ,
47
- message . guild . iconURL
48
- )
49
- . setThumbnail ( client . user . displayAvatarURL ( ) )
50
- . setFooter (
51
- `© ${ message . guild . me . displayName } | Developed by DistroByte & oof2win2 | Total Commands: ${ client . commands . size } ` ,
52
- client . user . displayAvatarURL ( )
53
- ) ;
54
- const roles = ( await getFactorioRoles ( user ) ) . roles ;
55
- rolesEmbed . addField ( "\u200B" , roles . join ( ", " ) ) ;
46
+ . setTitle ( "Roles of a Factorio player" )
47
+ . setDescription ( "Roles of a Factorio player" )
48
+ . setColor ( "GREEN" )
49
+ . setAuthor (
50
+ `${ message . guild . me . displayName } Help` ,
51
+ message . guild . iconURL
52
+ )
53
+ . setThumbnail ( client . user . displayAvatarURL ( ) )
54
+ . setFooter (
55
+ `© ${ message . guild . me . displayName } | Developed by DistroByte & oof2win2 | Total Commands: ${ client . commands . size } ` ,
56
+ client . user . displayAvatarURL ( )
57
+ ) ;
58
+ const roles = ( await getFactorioRoles ( user ) ) ;
59
+ if ( roles === null || roles === undefined ) return message . channel . send ( 'No roles!' ) ;
60
+ rolesEmbed . addField ( "\u200B" , roles . roles . join ( ", " ) ) ;
56
61
return message . channel . send ( rolesEmbed ) ;
57
62
} ,
58
63
} ;
0 commit comments