Skip to content

Commit 9f58e63

Browse files
committed
fix(admin): show all info about bot
1 parent c830043 commit 9f58e63

1 file changed

Lines changed: 10 additions & 25 deletions

File tree

src/controllers/admin/bots.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,21 @@ router.get("/get", async (req: Request, res: Response) => {
4646

4747
router.get("/getall", async (req: Request, res: Response) => {
4848
authorized(req, res, async () => {
49-
let bots;
50-
5149
try {
52-
bots = await RegisteredBot.find({
50+
const bots = await RegisteredBot.find({
5351
order: {
5452
username: "ASC",
5553
},
5654
});
55+
56+
return response(res, {
57+
status: HttpStatus.OK,
58+
message: `OK`,
59+
data: {
60+
count: bots.length,
61+
bots: bots,
62+
},
63+
});
5764
} catch (err) {
5865
req.log.fatal({
5966
msg: `Error locating bot`,
@@ -65,28 +72,6 @@ router.get("/getall", async (req: Request, res: Response) => {
6572
message: `Error retrieving information for bots`,
6673
});
6774
}
68-
69-
let bot_data = [];
70-
71-
bots.forEach((bot) => {
72-
bot_data.push({
73-
id: bot.id,
74-
username: bot.username,
75-
developer: bot.developer,
76-
token: bot.token,
77-
createdAt: bot.createdAt,
78-
updatedAt: bot.updatedAt,
79-
});
80-
});
81-
82-
return response(res, {
83-
status: HttpStatus.OK,
84-
message: `OK`,
85-
data: {
86-
count: bot_data.length,
87-
bots: bot_data,
88-
},
89-
});
9075
});
9176
});
9277

0 commit comments

Comments
 (0)