fix: Fix client state not updated after login

This commit is contained in:
BarryY 2025-05-16 16:26:39 +08:00
parent 2b4f2bc8e9
commit baba05c01d
1 changed files with 4 additions and 2 deletions

View File

@ -75,8 +75,10 @@ export const loginHandler: ToolHandler = async (args, context) => {
context.client.token = args.token;
}
// Attempt to log in with the token
await context.client.login(token);
// Attempt to log in with the token and get the ready client
const readyClient = await waitForReady(context.client, token);
// Update the context client with the ready client
context.client = readyClient;
return {
content: [{ type: "text", text: `Successfully logged in to Discord: ${context.client.user?.tag}` }]
};