Added 3th & 4th question to Quick Setup CLI

This commit is contained in:
DJj123dj
2025-04-20 12:08:52 +02:00
parent 2d1724893e
commit fd739054fd
3 changed files with 38 additions and 3 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ export class ODClientManager {
this.#debug.debug("Created client with permissions: "+this.permissions.join(", ")) this.#debug.debug("Created client with permissions: "+this.permissions.join(", "))
} }
/**Get all servers the bot is part of. */ /**Get all servers the bot is part of. */
getGuilds(){ async getGuilds(): Promise<discord.Guild[]> {
if (!this.initiated) throw new ODSystemError("Client isn't initiated yet!") if (!this.initiated) throw new ODSystemError("Client isn't initiated yet!")
if (!this.ready) throw new ODSystemError("Client isn't ready yet!") if (!this.ready) throw new ODSystemError("Client isn't ready yet!")
+36 -1
View File
@@ -1,6 +1,7 @@
import {opendiscord, api, utilities} from "../../index" import {opendiscord, api, utilities} from "../../index"
import {Terminal, terminal} from "terminal-kit" import {Terminal, terminal} from "terminal-kit"
import ansis from "ansis" import ansis from "ansis"
import * as discord from "discord.js"
import {renderHeader} from "./cli" import {renderHeader} from "./cli"
export async function renderQuickSetup(backFn:() => api.ODPromiseVoid){ export async function renderQuickSetup(backFn:() => api.ODPromiseVoid){
@@ -172,7 +173,41 @@ async function renderQuickSetupBotToken(backFn:() => api.ODPromiseVoid){
terminal.gray("Your bot should be online with the status 'Configuring Open Ticket...'.") terminal.gray("Your bot should be online with the status 'Configuring Open Ticket...'.")
await utilities.timer(3000) await utilities.timer(3000)
//continue //continue
//TODO await renderQuickSetupServer(result,async () => {await renderQuickSetupBotToken(backFn)})
} }
} }
} }
async function renderQuickSetupServer(client:api.ODClientManager,backFn:() => api.ODPromiseVoid){
renderHeader("⏱️ Open Ticket Quick Setup: Discord Server")
terminal.bold.blue("(Step 3) Please select a Discord Server to use.\n")
terminal.gray("The bot will only work in this server.\n\n")
const guilds = await client.getGuilds()
const nameList = guilds.map((g) => g.name)
const longestName = utilities.getLongestLength(nameList)
const guildList = guilds.map((g) => g.name.padEnd(longestName+5," ")+ansis.gray(" ("+g.id+")"))
const answer = await terminal.singleColumnMenu([ansis.green("🔄 <Refresh List>"),...guildList],{
leftPadding:"> ",
style:terminal.cyan,
selectedStyle:terminal.bgDefaultColor.bold,
submittedStyle:terminal.bgBlue,
extraLines:2,
cancelable:true
}).promise
if (answer.canceled) return backFn()
if (answer.selectedIndex == 0) return await renderQuickSetupServer(client,backFn)
const server = guilds[answer.selectedIndex-1]
await renderQuickSetupAdminRoles(client,server,[],async () => {await renderQuickSetupServer(client,backFn)})
}
async function renderQuickSetupAdminRoles(client:api.ODClientManager,guild:discord.Guild,selectedAdmins:string[],backFn:() => api.ODPromiseVoid){
renderHeader("⏱️ Open Ticket Quick Setup: Admin Roles")
terminal.bold.blue("(Step 4) Please select all 'Global Admins' roles to use.\n")
terminal.gray("Users with one of these roles will be able to access & interact with all tickets.\n\n")
}
+1 -1
View File
@@ -373,7 +373,7 @@ const main = async () => {
const client = opendiscord.client const client = opendiscord.client
//check if all servers are valid //check if all servers are valid
const botServers = client.getGuilds() const botServers = await client.getGuilds()
const generalConfig = opendiscord.configs.get("opendiscord:general") const generalConfig = opendiscord.configs.get("opendiscord:general")
const serverId = generalConfig.data.serverId ? generalConfig.data.serverId : "" const serverId = generalConfig.data.serverId ? generalConfig.data.serverId : ""
if (!serverId) throw new api.ODSystemError("Server Id Missing!") if (!serverId) throw new api.ODSystemError("Server Id Missing!")