qlaffont / fortnite-api

Fortnite API, Get Stats, News And Status
https://twitter.com/qlaffont
MIT License
354 stars 86 forks source link

Passing in usernames with spaces? #56

Closed mikesassatelli closed 6 years ago

mikesassatelli commented 6 years ago

Having some issues with users that have Epic Games usernames that contain spaces. I can send in the name of the user with the space, but it always returns user not found. Not sure if I'm doing something wrong or if the API isn't capable of handling spaces in usernames.

qlaffont commented 6 years ago

Can you provide an example of your code ? Because i don't have any problem actually with user with space ! Ex : https://stats-fortnite.com/battleroyale/profil/SLSV%20Curtini/pc

mikesassatelli commented 6 years ago

Sure. So I'm using this as part of a discord bot, and below is the code that takes the users message and splits it up basically. The first word is considered the command, and the rest are considered arguments.

const args = message.content.slice(config.prefix.length).trim().split(/ +/g); 
const command = args.shift().toLowerCase();`

The portion I'm having an issue with is while trying to check the users battle royale stats. Originally, a name with spaces would have been split into two separate arguments, so I've implemented using a comma rather than a space. I then manually modify the name by replacing the comma with a space.

if (command === "solo") {
    let name = args[0]
    name = name.replace(",", " ");
    let sys = args[1];

I've tested this and basically if a users enters the command "!solo Mike,Sass pc" the bot will interpret it as expected as "!solo Mike Sass pc" and set name = Mike Sass and sys = pc. It's obviously then later passed into the API using

fortniteAPI.getStatsBR(name, sys)

Yet for some reason if the name has a space it always return user not found.

mikesassatelli commented 6 years ago

Well shoot, I figured out the problem on my own, and it wasn't related to any of this. Thanks for the reply regardless!

Apollyon365 commented 5 years ago

I actually have a problem with this too, anyone knows the solution?