Merge branch 'main' of https://github.com/harmonyland/harmony
This commit is contained in:
commit
54b0356a72
2 changed files with 14 additions and 6 deletions
|
@ -10,11 +10,17 @@ import { RequestQueue } from './queue.ts'
|
||||||
import { APIRequest } from './request.ts'
|
import { APIRequest } from './request.ts'
|
||||||
|
|
||||||
function parseResponse(res: Response, raw: boolean): any {
|
function parseResponse(res: Response, raw: boolean): any {
|
||||||
if (raw) return res
|
let result
|
||||||
if (res.status === 204) return undefined
|
if (res.status === 204) result = Promise.resolve(undefined)
|
||||||
if (res.headers.get('content-type')?.startsWith('application/json') === true)
|
else if (
|
||||||
return res.json()
|
res.headers.get('content-type')?.startsWith('application/json') === true
|
||||||
return res.arrayBuffer().then((e) => new Uint8Array(e))
|
)
|
||||||
|
result = res.json()
|
||||||
|
else result = res.arrayBuffer().then((e) => new Uint8Array(e))
|
||||||
|
|
||||||
|
if (raw) {
|
||||||
|
return { response: res, body: result }
|
||||||
|
} else return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAPIOffset(serverDate: number | string): number {
|
function getAPIOffset(serverDate: number | string): number {
|
||||||
|
@ -197,7 +203,7 @@ export class BucketHandler {
|
||||||
|
|
||||||
let data
|
let data
|
||||||
try {
|
try {
|
||||||
data = await parseResponse(res, request.options.rawResponse ?? false)
|
data = await parseResponse(res, false)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new HTTPError(
|
throw new HTTPError(
|
||||||
err.message,
|
err.message,
|
||||||
|
|
|
@ -254,6 +254,8 @@ client.on('messageCreate', async (msg: Message) => {
|
||||||
buf += `\n${role.name === '@everyone' ? 'everyone' : role.name}`
|
buf += `\n${role.name === '@everyone' ? 'everyone' : role.name}`
|
||||||
}
|
}
|
||||||
msg.reply(buf)
|
msg.reply(buf)
|
||||||
|
} else if (msg.content === '!addrole') {
|
||||||
|
msg.member?.roles.add('837255383759716362')
|
||||||
} else if (msg.content === '!timer') {
|
} else if (msg.content === '!timer') {
|
||||||
msg.channel.send('3...').then((msg) => {
|
msg.channel.send('3...').then((msg) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Loading…
Reference in a new issue