@ -54,9 +54,11 @@ module.exports = {
}
}
if ( ! options . image . startsWith ( 'https://cdn.discordapp.com/attachments/' ) ) { return message . channel . send ( tags ? "You must provide a cdn.discordapp.com link." : "It seems you didn't upload an image, or there was an error on my side. If the problem persists, please contact my developers." ) ; }
if ( ! options . image . startsWith ( 'https://cdn.discordapp.com/attachments/' ) ) { return message . channel . send ( tags ? "You must provide a cdn.discordapp.com link." : "It seems you didn't upload an image, or there was an error on my side. If the problem persists, please contact my developers." ) ; }
if ( options . image . length > 350 ) { return message . channel . send ( "That image URL is a little too long." ) ; }
let rp = await RP . findOne ( { uid : message . author . id } ) || new RP ( { uid : message . author . id } ) ;
let rp = await RP . findOne ( { uid : message . author . id } ) || new RP ( { uid : message . author . id } ) ;
if ( rp . chars [ options . prefix ] ) { return message . channel . send ( "You already have a character with that prefix. Please try again with a different prefix." ) ; }
if ( rp . chars [ options . prefix ] ) { return message . channel . send ( "You already have a character with that prefix. Please try again with a different prefix." ) ; }
if ( Object . keys ( rp . chars ) . length >= 20 ) { return message . channel . send ( "The current maximum of characters is 20, and you've reached that maximum. Sorry!" ) ; }
rp . chars [ options . prefix ] = options ;
rp . chars [ options . prefix ] = options ;
rp . markModified ( ` chars. ${ options . prefix } ` ) ;
rp . markModified ( ` chars. ${ options . prefix } ` ) ;
rp . save ( ) ;
rp . save ( ) ;
@ -88,9 +90,69 @@ module.exports = {
. setTimestamp ( )
. setTimestamp ( )
] } ) ;
] } ) ;
} else if ( [ 'edit' , 'e' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
} else if ( [ 'edit' , 'e' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( ! args [ 1 ] ) { return message . channel . send ( ` Syntax: \` ${ prefix } rp edit <char> <> \` ` ) }
const rp = await RP . findOne ( { uid : message . author . id } ) ;
} else if ( [ 'delete' , 'd' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
if ( ! rp || ! Object . keys ( rp . chars ) . length ) { return message . channel . send ( "You don't have any characters to edit." ) ; }
if ( ! args [ 1 ] ) { return message . channel . send ( "You must provide the prefix of a character to edit!" ) ; }
if ( ! rp . chars [ args [ 1 ] . toLowerCase ( ) ] ) { return message . channel . send ( "A character with that prefix doesn't exist." ) ; }
let char = rp . chars [ args [ 1 ] . toLowerCase ( ) ] ;
if ( ! args [ 2 ] ) { return message . channel . send ( ` Syntax: \` ${ prefix } rp edit <char> <prefix|image|name> \` ` ) ; }
if ( [ 'p' , 'prefix' ] . includes ( args [ 2 ] . toLowerCase ( ) ) ) {
let old = char . prefix ;
let prefix ;
if ( ! args [ 3 ] ) {
prefix = await ask ( message , "What prefix would you like to set?" , 60000 ) ;
if ( ! prefix ) { return ; }
} else { prefix = args [ 3 ] ; }
prefix = prefix . toLowerCase ( ) ;
if ( prefix . length > 8 ) { return message . channel . send ( "Your prefix should be less than 8 characters." ) ; }
if ( ! prefix . match ( /^[a-zA-Z0-9-_]+$/ ) ) { return message . channel . send ( "Your prefix must contain only alphanumeric characters." ) ; }
if ( prefix === old ) { return message . channel . send ( "That's the same prefix you already had, silly!" ) ; }
char . prefix = prefix ;
delete rp . chars [ old ] ;
rp . chars [ prefix ] = char ;
[ 'chars' , ` chars. ${ old } ` , ` chars. ${ prefix } ` ] . forEach ( x => rp . markModified ( x ) ) ;
rp . save ( ) ;
return message . channel . send ( "Prefix saved!" ) ;
} else if ( [ 'i' , 'image' , 'img' ] . includes ( args [ 2 ] . toLowerCase ( ) ) ) {
let image ;
if ( ! args [ 3 ] ) {
image = await ask ( message , "What image would you like to set?" , 60000 ) ;
if ( ! image ) { return ; }
} else { image = args [ 3 ] ; }
if ( ! image . startsWith ( 'https://cdn.discordapp.com/attachments/' ) ) { return message . channel . send ( "You must provide a cdn.discordapp.com link." ) ; }
if ( image . length > 350 ) { return message . channel . send ( "That image URL is a little too long." ) ; }
rp . chars [ char . prefix ] . image = image ;
rp . markModified ( ` chars. ${ char . prefix } ` ) ;
rp . save ( ) ;
return message . channel . send ( "Image saved!" ) ;
} else if ( [ 'n' , 'name' ] . includes ( args [ 2 ] . toLowerCase ( ) ) ) {
args = args . slice ( 3 ) ;
let name ;
if ( ! args [ 0 ] ) {
name = await ask ( message , "What name would you like to set?" , 60000 ) ;
if ( ! name ) { return ; }
} else { name = args . join ( " " ) ; }
if ( name . length > 75 ) { return message . channel . send ( "That name is a little too long." ) ; }
rp . chars [ char . prefix ] . name = name ;
rp . markModified ( ` chars. ${ char . prefix } ` ) ;
rp . save ( ) ;
return message . channel . send ( "Name saved!" ) ;
} else { return message . channel . send ( ` Invalid arg! Syntax: \` ${ prefix } rp edit <char> <prefix|image|name> \` ` ) ; }
} else if ( [ 'delete' , 'd' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
const rp = await RP . findOne ( { uid : message . author . id } ) ;
if ( ! rp || ! Object . keys ( rp . chars ) . length ) { return message . channel . send ( "You don't have any characters to delete." ) ; }
if ( ! args [ 1 ] ) { return message . channel . send ( "You must provide the prefix of a character to delete!" ) ; }
if ( ! rp . chars [ args [ 1 ] . toLowerCase ( ) ] ) { return message . channel . send ( "A character with that prefix doesn't exist." ) ; }
let char = rp . chars [ args [ 1 ] . toLowerCase ( ) ] ;
let conf = await ask ( message , ` Are you sure you want to delete ${ char . name } ? ` , 60000 ) ;
if ( ! conf ) { return ; }
if ( ! [ 'yes' , 'y' , 'sure' , 'mhm' , 'ye' ] . includes ( conf . toLowerCase ( ) ) ) { return message . channel . send ( "Okay, I won't do anything then." ) ; }
delete rp . chars [ char . prefix ] ;
rp . markModified ( ` chars. ${ char . prefix } ` ) ;
rp . save ( ) ;
return message . channel . send ( "I've deleted that character for you." ) ;
} else if ( [ 'enable' , 'en' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
} else if ( [ 'enable' , 'en' ] . includes ( args [ 0 ] . toLowerCase ( ) ) ) {
}
}