Skip to content

Commit

Permalink
(lint): fix linting on publishToTopic
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbixby committed Jun 8, 2024
1 parent 5546771 commit 66d0aa1
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions lib/games/publishToTopic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,34 @@ exports.optional = ['jar']

function publishToTopic (universeId, topic, data, jar) {
return new Promise((resolve, reject) => {

const httpOpt = {
url: `//apis.roblox.com/messaging-service/v1/universes/${universeId}/topics/${topic}`,
options: {
json: true,
resolveWithFullResponse: true,
jar,
method: 'POST',
body: { message: JSON.stringify(data) },
headers: {
'Content-Type': 'application/json'
}
options: {
json: true,
resolveWithFullResponse: true,
jar,
method: 'POST',
body: { message: JSON.stringify(data) },
headers: {
'Content-Type': 'application/json'
}
}
}

return http(httpOpt)
.then(function (res) {
if (res.statusCode === 200) {
resolve(true)
} else {
if (typeof(res.body) === "string") {
reject(new Error(`[${res.statusCode}] ${res.statusMessage} ${res.body}`))
return http(httpOpt)
.then(function (res) {
if (res.statusCode === 200) {
resolve(true)
} else {
const data = Object.assign(res.body)
reject(new Error(`[${res.statusCode}] ${data.Error} ${data.Message}`))
if (typeof (res.body) === 'string') {
reject(new Error(`[${res.statusCode}] ${res.statusMessage} ${res.body}`))
} else {
const data = Object.assign(res.body)
reject(new Error(`[${res.statusCode}] ${data.Error} ${data.Message}`))
}
}
}
})
.catch(reject)
})
.catch(reject)
})
}

Expand Down

0 comments on commit 66d0aa1

Please sign in to comment.