847 lines
23 KiB
JavaScript
847 lines
23 KiB
JavaScript
// This file is autogenerated by the hyperschema compiler
|
|
// Schema Version: 8
|
|
/* eslint-disable camelcase */
|
|
/* eslint-disable quotes */
|
|
/* eslint-disable space-before-function-paren */
|
|
|
|
const { c } = require('hyperschema/runtime')
|
|
|
|
const VERSION = 8
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
let version = VERSION
|
|
|
|
// @pearcord/user
|
|
const encoding0 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.username)
|
|
c.string.preencode(state, m.discriminator)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.displayName) c.string.preencode(state, m.displayName)
|
|
if (m.avatarHash) c.string.preencode(state, m.avatarHash)
|
|
c.string.preencode(state, m.publicKey)
|
|
if (m.status) c.string.preencode(state, m.status)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (m.displayName ? 1 : 0) | (m.avatarHash ? 2 : 0) | (m.status ? 4 : 0)
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.username)
|
|
c.string.encode(state, m.discriminator)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.displayName) c.string.encode(state, m.displayName)
|
|
if (m.avatarHash) c.string.encode(state, m.avatarHash)
|
|
c.string.encode(state, m.publicKey)
|
|
if (m.status) c.string.encode(state, m.status)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
username: r1,
|
|
discriminator: r2,
|
|
displayName: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
avatarHash: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
publicKey: c.string.decode(state),
|
|
status: (flags & 4) !== 0 ? c.string.decode(state) : null,
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/guild
|
|
const encoding1 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.name)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.iconHash) c.string.preencode(state, m.iconHash)
|
|
c.string.preencode(state, m.ownerId)
|
|
c.string.preencode(state, m.topic)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = m.iconHash ? 1 : 0
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.name)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.iconHash) c.string.encode(state, m.iconHash)
|
|
c.string.encode(state, m.ownerId)
|
|
c.string.encode(state, m.topic)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
name: r1,
|
|
iconHash: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
ownerId: c.string.decode(state),
|
|
topic: c.string.decode(state),
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/channel
|
|
const encoding2 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.name)
|
|
c.string.preencode(state, m.type)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.parentId) c.string.preencode(state, m.parentId)
|
|
c.uint.preencode(state, m.position)
|
|
if (m.topic) c.string.preencode(state, m.topic)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (m.parentId ? 1 : 0) | (m.topic ? 2 : 0)
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.name)
|
|
c.string.encode(state, m.type)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.parentId) c.string.encode(state, m.parentId)
|
|
c.uint.encode(state, m.position)
|
|
if (m.topic) c.string.encode(state, m.topic)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
guildId: r1,
|
|
name: r2,
|
|
type: r3,
|
|
parentId: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
position: c.uint.decode(state),
|
|
topic: (flags & 2) !== 0 ? c.string.decode(state) : null
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/message
|
|
const encoding3 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.channelId)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.authorId)
|
|
c.string.preencode(state, m.content)
|
|
c.uint.preencode(state, m.createdAt)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.editedAt) c.uint.preencode(state, m.editedAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = m.editedAt ? 1 : 0
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.channelId)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.authorId)
|
|
c.string.encode(state, m.content)
|
|
c.uint.encode(state, m.createdAt)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.editedAt) c.uint.encode(state, m.editedAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const r4 = c.string.decode(state)
|
|
const r5 = c.uint.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
channelId: r1,
|
|
guildId: r2,
|
|
authorId: r3,
|
|
content: r4,
|
|
createdAt: r5,
|
|
editedAt: (flags & 1) !== 0 ? c.uint.decode(state) : 0
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/member
|
|
const encoding4 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.userId)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.nickname) c.string.preencode(state, m.nickname)
|
|
if (m.roles) c.string.preencode(state, m.roles)
|
|
c.uint.preencode(state, m.joinedAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (m.nickname ? 1 : 0) | (m.roles ? 2 : 0) | (m.isBot ? 4 : 0)
|
|
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.userId)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.nickname) c.string.encode(state, m.nickname)
|
|
if (m.roles) c.string.encode(state, m.roles)
|
|
c.uint.encode(state, m.joinedAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
guildId: r0,
|
|
userId: r1,
|
|
nickname: (flags & 1) !== 0 ? c.string.decode(state) : null,
|
|
roles: (flags & 2) !== 0 ? c.string.decode(state) : null,
|
|
joinedAt: c.uint.decode(state),
|
|
isBot: (flags & 4) !== 0
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/invite
|
|
const encoding5 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.code)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.creatorId)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (m.maxUses) c.uint.preencode(state, m.maxUses)
|
|
c.uint.preencode(state, m.uses)
|
|
if (m.expiresAt) c.uint.preencode(state, m.expiresAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (m.maxUses ? 1 : 0) | (m.expiresAt ? 2 : 0)
|
|
|
|
c.string.encode(state, m.code)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.creatorId)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (m.maxUses) c.uint.encode(state, m.maxUses)
|
|
c.uint.encode(state, m.uses)
|
|
if (m.expiresAt) c.uint.encode(state, m.expiresAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
code: r0,
|
|
guildId: r1,
|
|
creatorId: r2,
|
|
maxUses: (flags & 1) !== 0 ? c.uint.decode(state) : 0,
|
|
uses: c.uint.decode(state),
|
|
expiresAt: (flags & 2) !== 0 ? c.uint.decode(state) : 0
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/bot
|
|
const encoding6 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.name)
|
|
c.string.preencode(state, m.publicKey)
|
|
c.string.preencode(state, m.ownerId)
|
|
c.uint.preencode(state, m.intents)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.name)
|
|
c.string.encode(state, m.publicKey)
|
|
c.string.encode(state, m.ownerId)
|
|
c.uint.encode(state, m.intents)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const r4 = c.uint.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
name: r1,
|
|
publicKey: r2,
|
|
ownerId: r3,
|
|
intents: r4
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/reaction
|
|
const encoding7 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.channelId)
|
|
c.string.preencode(state, m.messageId)
|
|
c.string.preencode(state, m.emoji)
|
|
c.string.preencode(state, m.userId)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (version >= 2 && m.guildId) c.string.preencode(state, m.guildId)
|
|
if (version >= 2 && m.createdAt) c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = ((version >= 2 && m.guildId) ? 1 : 0) | ((version >= 2 && m.createdAt) ? 2 : 0)
|
|
|
|
c.string.encode(state, m.channelId)
|
|
c.string.encode(state, m.messageId)
|
|
c.string.encode(state, m.emoji)
|
|
c.string.encode(state, m.userId)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (version >= 2 && m.guildId) c.string.encode(state, m.guildId)
|
|
if (version >= 2 && m.createdAt) c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
channelId: r0,
|
|
messageId: r1,
|
|
emoji: r2,
|
|
userId: r3,
|
|
guildId: (version >= 2 && (flags & 1) !== 0) ? c.string.decode(state) : null,
|
|
createdAt: (version >= 2 && (flags & 2) !== 0) ? c.uint.decode(state) : 0
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/readState
|
|
const encoding8 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.userId)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.channelId)
|
|
c.uint.preencode(state, m.lastReadAt)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.userId)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.channelId)
|
|
c.uint.encode(state, m.lastReadAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.uint.decode(state)
|
|
|
|
return {
|
|
userId: r0,
|
|
guildId: r1,
|
|
channelId: r2,
|
|
lastReadAt: r3
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/pin
|
|
const encoding9 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.channelId)
|
|
c.string.preencode(state, m.messageId)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.pinnedBy)
|
|
c.uint.preencode(state, m.pinnedAt)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.channelId)
|
|
c.string.encode(state, m.messageId)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.pinnedBy)
|
|
c.uint.encode(state, m.pinnedAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const r4 = c.uint.decode(state)
|
|
|
|
return {
|
|
channelId: r0,
|
|
messageId: r1,
|
|
guildId: r2,
|
|
pinnedBy: r3,
|
|
pinnedAt: r4
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/ban
|
|
const encoding10 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.userId)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (version >= 3 && m.reason) c.string.preencode(state, m.reason)
|
|
c.string.preencode(state, m.bannedBy)
|
|
c.uint.preencode(state, m.bannedAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (version >= 3 && m.reason) ? 1 : 0
|
|
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.userId)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (version >= 3 && m.reason) c.string.encode(state, m.reason)
|
|
c.string.encode(state, m.bannedBy)
|
|
c.uint.encode(state, m.bannedAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
guildId: r0,
|
|
userId: r1,
|
|
reason: (version >= 3 && (flags & 1) !== 0) ? c.string.decode(state) : null,
|
|
bannedBy: c.string.decode(state),
|
|
bannedAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/channelSettings
|
|
const encoding11 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.channelId)
|
|
c.uint.preencode(state, m.slowmodeSeconds)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.channelId)
|
|
c.uint.encode(state, m.slowmodeSeconds)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.uint.decode(state)
|
|
|
|
return {
|
|
guildId: r0,
|
|
channelId: r1,
|
|
slowmodeSeconds: r2
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/rateLimit
|
|
const encoding12 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.userId)
|
|
c.string.preencode(state, m.channelId)
|
|
c.uint.preencode(state, m.lastSentAt)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.userId)
|
|
c.string.encode(state, m.channelId)
|
|
c.uint.encode(state, m.lastSentAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.uint.decode(state)
|
|
|
|
return {
|
|
userId: r0,
|
|
channelId: r1,
|
|
lastSentAt: r2
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/mentionAlert
|
|
const encoding13 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.userId)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.channelId)
|
|
c.uint.preencode(state, m.count)
|
|
c.uint.preencode(state, m.updatedAt)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.userId)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.channelId)
|
|
c.uint.encode(state, m.count)
|
|
c.uint.encode(state, m.updatedAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.uint.decode(state)
|
|
const r4 = c.uint.decode(state)
|
|
|
|
return {
|
|
userId: r0,
|
|
guildId: r1,
|
|
channelId: r2,
|
|
count: r3,
|
|
updatedAt: r4
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/auditEntry
|
|
const encoding14 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.actorId)
|
|
c.string.preencode(state, m.action)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (version >= 4 && m.targetId) c.string.preencode(state, m.targetId)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (version >= 4 && m.targetId) ? 1 : 0
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.actorId)
|
|
c.string.encode(state, m.action)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (version >= 4 && m.targetId) c.string.encode(state, m.targetId)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
guildId: r1,
|
|
actorId: r2,
|
|
action: r3,
|
|
targetId: (version >= 4 && (flags & 1) !== 0) ? c.string.decode(state) : null,
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/attachment
|
|
const encoding15 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.channelId)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (version >= 5 && m.messageId) c.string.preencode(state, m.messageId)
|
|
c.string.preencode(state, m.authorId)
|
|
c.string.preencode(state, m.filename)
|
|
c.string.preencode(state, m.mimeType)
|
|
c.uint.preencode(state, m.size)
|
|
c.string.preencode(state, m.localPath)
|
|
if (version >= 5 && m.driveKey) c.string.preencode(state, m.driveKey)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = ((version >= 5 && m.messageId) ? 1 : 0) | ((version >= 5 && m.driveKey) ? 2 : 0)
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.channelId)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (version >= 5 && m.messageId) c.string.encode(state, m.messageId)
|
|
c.string.encode(state, m.authorId)
|
|
c.string.encode(state, m.filename)
|
|
c.string.encode(state, m.mimeType)
|
|
c.uint.encode(state, m.size)
|
|
c.string.encode(state, m.localPath)
|
|
if (version >= 5 && m.driveKey) c.string.encode(state, m.driveKey)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
guildId: r1,
|
|
channelId: r2,
|
|
messageId: (version >= 5 && (flags & 1) !== 0) ? c.string.decode(state) : null,
|
|
authorId: c.string.decode(state),
|
|
filename: c.string.decode(state),
|
|
mimeType: c.string.decode(state),
|
|
size: c.uint.decode(state),
|
|
localPath: c.string.decode(state),
|
|
driveKey: (version >= 5 && (flags & 2) !== 0) ? c.string.decode(state) : null,
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/threadMeta
|
|
const encoding16 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.channelId)
|
|
c.string.preencode(state, m.rootMessageId)
|
|
state.end++ // flags are fixed size
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags = (version >= 6 && m.archived) ? 1 : 0
|
|
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.channelId)
|
|
c.string.encode(state, m.rootMessageId)
|
|
c.uint8.encode(state, flags)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
guildId: r0,
|
|
channelId: r1,
|
|
rootMessageId: r2,
|
|
archived: (version >= 6 && (flags & 1) !== 0),
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/slashCommand
|
|
const encoding17 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.name)
|
|
c.string.preencode(state, m.description)
|
|
state.end++ // flags are fixed size
|
|
|
|
if (version >= 7 && m.optionsJson) c.string.preencode(state, m.optionsJson)
|
|
if (version >= 7 && m.applicationId) c.string.preencode(state, m.applicationId)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
const flags =
|
|
((version >= 7 && m.optionsJson) ? 1 : 0) |
|
|
((version >= 7 && m.applicationId) ? 2 : 0) |
|
|
((version >= 7 && m.builtin) ? 4 : 0)
|
|
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.name)
|
|
c.string.encode(state, m.description)
|
|
c.uint8.encode(state, flags)
|
|
|
|
if (version >= 7 && m.optionsJson) c.string.encode(state, m.optionsJson)
|
|
if (version >= 7 && m.applicationId) c.string.encode(state, m.applicationId)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const flags = c.uint8.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
guildId: r1,
|
|
name: r2,
|
|
description: r3,
|
|
optionsJson: (version >= 7 && (flags & 1) !== 0) ? c.string.decode(state) : null,
|
|
applicationId: (version >= 7 && (flags & 2) !== 0) ? c.string.decode(state) : null,
|
|
builtin: (version >= 7 && (flags & 4) !== 0),
|
|
createdAt: c.uint.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
// @pearcord/guildBot
|
|
const encoding18 = {
|
|
preencode(state, m) {
|
|
c.string.preencode(state, m.id)
|
|
c.string.preencode(state, m.guildId)
|
|
c.string.preencode(state, m.name)
|
|
c.string.preencode(state, m.publicKey)
|
|
c.string.preencode(state, m.ownerId)
|
|
c.uint.preencode(state, m.intents)
|
|
c.uint.preencode(state, m.createdAt)
|
|
},
|
|
encode(state, m) {
|
|
c.string.encode(state, m.id)
|
|
c.string.encode(state, m.guildId)
|
|
c.string.encode(state, m.name)
|
|
c.string.encode(state, m.publicKey)
|
|
c.string.encode(state, m.ownerId)
|
|
c.uint.encode(state, m.intents)
|
|
c.uint.encode(state, m.createdAt)
|
|
},
|
|
decode(state) {
|
|
const r0 = c.string.decode(state)
|
|
const r1 = c.string.decode(state)
|
|
const r2 = c.string.decode(state)
|
|
const r3 = c.string.decode(state)
|
|
const r4 = c.string.decode(state)
|
|
const r5 = c.uint.decode(state)
|
|
const r6 = c.uint.decode(state)
|
|
|
|
return {
|
|
id: r0,
|
|
guildId: r1,
|
|
name: r2,
|
|
publicKey: r3,
|
|
ownerId: r4,
|
|
intents: r5,
|
|
createdAt: r6
|
|
}
|
|
}
|
|
}
|
|
|
|
function setVersion(v) {
|
|
version = v
|
|
}
|
|
|
|
function encode(name, value, v = VERSION) {
|
|
version = v
|
|
return c.encode(getEncoding(name), value)
|
|
}
|
|
|
|
function decode(name, buffer, v = VERSION) {
|
|
version = v
|
|
return c.decode(getEncoding(name), buffer)
|
|
}
|
|
|
|
function getEnum(name) {
|
|
switch (name) {
|
|
default:
|
|
throw new Error('Enum not found ' + name)
|
|
}
|
|
}
|
|
|
|
function getEncoding(name) {
|
|
switch (name) {
|
|
case '@pearcord/user':
|
|
return encoding0
|
|
case '@pearcord/guild':
|
|
return encoding1
|
|
case '@pearcord/channel':
|
|
return encoding2
|
|
case '@pearcord/message':
|
|
return encoding3
|
|
case '@pearcord/member':
|
|
return encoding4
|
|
case '@pearcord/invite':
|
|
return encoding5
|
|
case '@pearcord/bot':
|
|
return encoding6
|
|
case '@pearcord/reaction':
|
|
return encoding7
|
|
case '@pearcord/readState':
|
|
return encoding8
|
|
case '@pearcord/pin':
|
|
return encoding9
|
|
case '@pearcord/ban':
|
|
return encoding10
|
|
case '@pearcord/channelSettings':
|
|
return encoding11
|
|
case '@pearcord/rateLimit':
|
|
return encoding12
|
|
case '@pearcord/mentionAlert':
|
|
return encoding13
|
|
case '@pearcord/auditEntry':
|
|
return encoding14
|
|
case '@pearcord/attachment':
|
|
return encoding15
|
|
case '@pearcord/threadMeta':
|
|
return encoding16
|
|
case '@pearcord/slashCommand':
|
|
return encoding17
|
|
case '@pearcord/guildBot':
|
|
return encoding18
|
|
default:
|
|
throw new Error('Encoder not found ' + name)
|
|
}
|
|
}
|
|
|
|
function getStruct(name, v = VERSION) {
|
|
const enc = getEncoding(name)
|
|
return {
|
|
preencode(state, m) {
|
|
version = v
|
|
enc.preencode(state, m)
|
|
},
|
|
encode(state, m) {
|
|
version = v
|
|
enc.encode(state, m)
|
|
},
|
|
decode(state) {
|
|
version = v
|
|
return enc.decode(state)
|
|
}
|
|
}
|
|
}
|
|
|
|
const resolveStruct = getStruct // compat
|
|
|
|
module.exports = {
|
|
resolveStruct,
|
|
getStruct,
|
|
getEnum,
|
|
getEncoding,
|
|
encode,
|
|
decode,
|
|
setVersion,
|
|
version
|
|
}
|