changing spaces to tabs
This commit is contained in:
@@ -18,10 +18,10 @@ passthrough.discord = discord
|
||||
|
||||
;(async () => {
|
||||
await discord.cloud.connect()
|
||||
console.log("Discord gateway started")
|
||||
console.log("Discord gateway started")
|
||||
|
||||
const f = event => onPacket(discord, event, () => discord.cloud.off("event", f))
|
||||
discord.cloud.on("event", f)
|
||||
const f = event => onPacket(discord, event, () => discord.cloud.off("event", f))
|
||||
discord.cloud.on("event", f)
|
||||
})()
|
||||
|
||||
const expectedGuilds = new Set()
|
||||
@@ -30,29 +30,29 @@ const prepared = db.prepare("UPDATE channel_room SET name = ? WHERE channel_id =
|
||||
|
||||
/** @param {DiscordClient} discord */
|
||||
function onPacket(discord, event, unsubscribe) {
|
||||
if (event.t === "READY") {
|
||||
for (const obj of event.d.guilds) {
|
||||
expectedGuilds.add(obj.id)
|
||||
}
|
||||
if (event.t === "READY") {
|
||||
for (const obj of event.d.guilds) {
|
||||
expectedGuilds.add(obj.id)
|
||||
}
|
||||
|
||||
} else if (event.t === "GUILD_CREATE") {
|
||||
expectedGuilds.delete(event.d.id)
|
||||
} else if (event.t === "GUILD_CREATE") {
|
||||
expectedGuilds.delete(event.d.id)
|
||||
|
||||
// Store the channel.
|
||||
for (const channel of event.d.channels || []) {
|
||||
prepared.run(channel.name, channel.id)
|
||||
}
|
||||
// Store the channel.
|
||||
for (const channel of event.d.channels || []) {
|
||||
prepared.run(channel.name, channel.id)
|
||||
}
|
||||
|
||||
// Checked them all?
|
||||
if (expectedGuilds.size === 0) {
|
||||
discord.cloud.disconnect()
|
||||
unsubscribe()
|
||||
// Checked them all?
|
||||
if (expectedGuilds.size === 0) {
|
||||
discord.cloud.disconnect()
|
||||
unsubscribe()
|
||||
|
||||
// I don't know why node keeps running.
|
||||
setTimeout(() => {
|
||||
console.log("Stopping now.")
|
||||
process.exit()
|
||||
}, 1500).unref()
|
||||
}
|
||||
}
|
||||
// I don't know why node keeps running.
|
||||
setTimeout(() => {
|
||||
console.log("Stopping now.")
|
||||
process.exit()
|
||||
}, 1500).unref()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user