40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { promptForInput } from "../util/general.js";
|
|
import { logError, logSuccess, logWarning } from "../util/logger.js";
|
|
import { setupClient } from "./setup-client.js";
|
|
|
|
const botname = await promptForInput("enter bot username: ");
|
|
const developers = (
|
|
await promptForInput("enter developer usernames (,separated): ")
|
|
).split(",");
|
|
|
|
const getUid = async (username: string) => {
|
|
const user = await setupClient.users.getUserByName(username);
|
|
if (user?.id) {
|
|
logSuccess(`${user.name} => ${user.id}`);
|
|
return user.id;
|
|
}
|
|
logWarning(`no user with name ${username} found`);
|
|
return "";
|
|
};
|
|
|
|
const botId = await getUid(botname);
|
|
if (!botId) {
|
|
logError("bot not found. please check the configuration");
|
|
throw new Error();
|
|
}
|
|
|
|
const developerIds = [];
|
|
for (const dev of developers) {
|
|
const devId = await getUid(dev);
|
|
if (devId) {
|
|
developerIds.push(devId);
|
|
} else {
|
|
logWarning(`dev '${dev}' not found. please check the configuration`);
|
|
}
|
|
}
|
|
|
|
logSuccess(`Userid of bot '${botname}' => '${botId}'`);
|
|
logSuccess(
|
|
`Userids of developers '${developers.join(",")}' => '${developerIds.join(",")}'`,
|
|
);
|