74 |
return true; |
return true; |
75 |
}; |
}; |
76 |
|
|
|
let prefix = '-', homeGuild = '', owners = []; |
|
|
|
|
77 |
(async () => { |
(async () => { |
78 |
console.log(`SudoBot version ${version}`); |
console.log(`SudoBot version ${version}`); |
79 |
console.log(`Copyright (C) OSN Inc 2022`); |
console.log(`Copyright (C) OSN Inc 2022`); |
80 |
console.log(`Thanks for using SudoBot! We'll much appreciate if you star the repository on GitHub.\n`); |
console.log(`Thanks for using SudoBot! We'll much appreciate if you star the repository on GitHub.\n`); |
81 |
|
|
82 |
|
let prefix = '-', homeGuild = '', owners = []; |
83 |
|
let config = Object.entries(JSON.parse((await fs.readFile(SAMPLE_CONFIG_PATH)).toString())); |
84 |
|
|
85 |
prefix = (await promptLoop(`What will be the bot prefix? [${prefix}]: `, input => { |
config[1][1].prefix = (await promptLoop(`What will be the bot prefix? [${prefix}]: `, input => { |
86 |
if (input.trim().includes(' ')) { |
if (input.trim().includes(' ')) { |
87 |
console.log(`Prefixes must not contain spaces!`); |
console.log(`Prefixes must not contain spaces!`); |
88 |
return false; |
return false; |
89 |
} |
} |
90 |
|
|
91 |
return true; |
return true; |
92 |
}, prefix)).trim(); |
}, "-")).trim(); |
93 |
|
|
94 |
homeGuild = await promptLoop(`What will be the Home/Support Guild ID?: `, snowflakeValidator); |
homeGuild = await promptLoop(`What will be the Home/Support Guild ID?: `, snowflakeValidator); |
95 |
owners = (await promptLoop(`Who will be the owner? Specify the owner user IDs separated with comma (,): `, input => { |
config[1][0] = homeGuild; |
96 |
|
|
97 |
|
config = Object.fromEntries(config); |
98 |
|
|
99 |
|
config.global.id = homeGuild; |
100 |
|
config.global.owners = (await promptLoop(`Who will be the owner? Specify the owner user IDs separated with comma (,): `, input => { |
101 |
const splitted = input.split(','); |
const splitted = input.split(','); |
102 |
|
|
103 |
for (const snowflake of splitted) { |
for (const snowflake of splitted) { |
110 |
return true; |
return true; |
111 |
})).split(',').map(s => s.trim()); |
})).split(',').map(s => s.trim()); |
112 |
|
|
113 |
let config = Object.entries(JSON.parse((await fs.readFile(SAMPLE_CONFIG_PATH)).toString())); |
// config[1][0] = homeGuild; |
114 |
config[1][0] = homeGuild; |
// config[1][1].prefix = prefix; |
|
config[1][1].prefix = prefix; |
|
|
config = Object.fromEntries(config); |
|
115 |
|
|
116 |
config.global.id = homeGuild; |
// config.global.owners = owners; |
117 |
config.global.owners = owners; |
|
118 |
|
const guildConfig = {...config[homeGuild]}; |
119 |
|
|
120 |
|
guildConfig.mod_role = await promptLoop(`What will be the moderator role ID?: `, snowflakeValidator); |
121 |
|
guildConfig.admin = await promptLoop(`What will be the safe role ID?: `, snowflakeValidator); |
122 |
|
guildConfig.mute_role = await promptLoop(`What will be the muted role ID?: `, snowflakeValidator); |
123 |
|
guildConfig.gen_role = await promptLoop(`What will be the general role ID? [${homeGuild}]: `, snowflakeValidator, homeGuild); |
124 |
|
guildConfig.logging_channel = await promptLoop(`What will be the main logging channel ID?: `, snowflakeValidator); |
125 |
|
guildConfig.logging_channel_join_leave = await promptLoop(`What will be the join/leave logging channel ID?: `, snowflakeValidator); |
126 |
|
|
127 |
|
config[homeGuild] = guildConfig; |
128 |
|
|
129 |
console.log(config); |
console.log(config); |
130 |
|
|
140 |
|
|
141 |
rl.close(); |
rl.close(); |
142 |
|
|
143 |
|
if (existsSync(CONFIG_PATH)) |
144 |
|
await fs.rename(CONFIG_PATH, path.join(CONFIG_DIR, 'config-old-' + Math.round(Math.random() * 100000) + '.json')); |
145 |
|
|
146 |
|
await fs.writeFile(CONFIG_PATH, JSON.stringify(config, undefined, ' ')); |
147 |
|
|
148 |
console.log("Setup complete!"); |
console.log("Setup complete!"); |
149 |
console.table([ |
console.table([ |
150 |
{ |
{ |