More accurate flags check in setup
This commit is contained in:
+12
-7
@@ -184,17 +184,21 @@ function defineEchoHandler() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const mandatoryIntentFlags = DiscordTypes.ApplicationFlags.GatewayMessageContent | DiscordTypes.ApplicationFlags.GatewayMessageContentLimited
|
const intentFlagPossibilities = [
|
||||||
if (!(client.flags & mandatoryIntentFlags)) {
|
DiscordTypes.ApplicationFlags.GatewayMessageContent | DiscordTypes.ApplicationFlags.GatewayPresence,
|
||||||
|
DiscordTypes.ApplicationFlags.GatewayMessageContentLimited | DiscordTypes.ApplicationFlags.GatewayPresenceLimited
|
||||||
|
]
|
||||||
|
const intentFlagMask = intentFlagPossibilities.reduce((a, c) => a | c, 0)
|
||||||
|
if (!intentFlagPossibilities.includes(client.flags & intentFlagMask)) {
|
||||||
console.log(`On that same page, scroll down to Privileged Gateway Intents and enable all switches.`)
|
console.log(`On that same page, scroll down to Privileged Gateway Intents and enable all switches.`)
|
||||||
await prompt({
|
await prompt({
|
||||||
type: "invisible",
|
type: "invisible",
|
||||||
name: "intents",
|
name: "intents",
|
||||||
message: "Press Enter when you've enabled them",
|
message: "Press Enter when you've enabled them",
|
||||||
validate: async token => {
|
validate: async () => {
|
||||||
process.stdout.write(magenta("checking, please wait..."))
|
process.stdout.write(magenta("checking, please wait..."))
|
||||||
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
||||||
if (client.flags & mandatoryIntentFlags) {
|
if (intentFlagPossibilities.includes(client.flags & intentFlagMask)) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return "Switches have not been enabled yet"
|
return "Switches have not been enabled yet"
|
||||||
@@ -220,7 +224,7 @@ function defineEchoHandler() {
|
|||||||
type: "invisible",
|
type: "invisible",
|
||||||
name: "description",
|
name: "description",
|
||||||
message: "Press Enter to acknowledge",
|
message: "Press Enter to acknowledge",
|
||||||
validate: async token => {
|
validate: async () => {
|
||||||
process.stdout.write(magenta("checking, please wait..."))
|
process.stdout.write(magenta("checking, please wait..."))
|
||||||
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
||||||
if (client.description?.match(/out.of.your.element/i)) {
|
if (client.description?.match(/out.of.your.element/i)) {
|
||||||
@@ -237,7 +241,8 @@ function defineEchoHandler() {
|
|||||||
const clientSecretResponse = await prompt({
|
const clientSecretResponse = await prompt({
|
||||||
type: "input",
|
type: "input",
|
||||||
name: "discord_client_secret",
|
name: "discord_client_secret",
|
||||||
message: "Client secret"
|
message: "Client secret",
|
||||||
|
validate: secret => !!secret
|
||||||
})
|
})
|
||||||
|
|
||||||
const expectedUri = `${bridgeOriginResponse.bridge_origin}/oauth`
|
const expectedUri = `${bridgeOriginResponse.bridge_origin}/oauth`
|
||||||
@@ -247,7 +252,7 @@ function defineEchoHandler() {
|
|||||||
type: "invisible",
|
type: "invisible",
|
||||||
name: "redirect_uri",
|
name: "redirect_uri",
|
||||||
message: "Press Enter when you've added it",
|
message: "Press Enter when you've added it",
|
||||||
validate: async token => {
|
validate: async () => {
|
||||||
process.stdout.write(magenta("checking, please wait..."))
|
process.stdout.write(magenta("checking, please wait..."))
|
||||||
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
client = await snow.requestHandler.request(`/applications/@me`, {}, "get", "json")
|
||||||
if (client.redirect_uris.includes(expectedUri)) {
|
if (client.redirect_uris.includes(expectedUri)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user