Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I use the agent?#9503

Unanswered
sukbearai asked this question inQ&A
May 2, 2023· 6 comments· 1 reply
Discussion options

Which package is this bug report for?

discord.js

Issue description

I'm using the agent, but I'm encountering an error.

image

Code sample

// Require the necessary discord.js classesconst{ Client, Events, GatewayIntentBits}=require('discord.js');const{ token}=require('./config.json');import{ProxyAgent}from'undici';// Create a new client instanceconstclient=newClient({intents:[GatewayIntentBits.Guilds],rest:{agent:newProxyAgent(`http://127.0.0.1:7890`)}});// When the client is ready, run this code (only once)// We use 'c' for the event parameter to keep it separate from the already defined 'client'client.once(Events.ClientReady,c=>{console.log(`Ready! Logged in as${c.user.tag}`);});// Log in to Discord with your client's tokenclient.login(token);

No response

Versions

  • discord.js 14.9.0 (npm ls discord.js or another package)
  • Node.js 16.9.0 (node --version)
  • TypeScript 5.0.4 (npm ls typescript if you use it)
  • macOS Ventura 13.3.1

Issue priority

High (immediate attention needed)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds

I have tested this issue on a development release

No response

You must be logged in to vote

Replies: 6 comments 1 reply

Comment options

@sukbearsuwu Can you catch the error on the login?

client.login(token).catch(error=>{console.error(`An error occurred while logging in:${error.message}`);});
You must be logged in to vote
0 replies
Comment options

'use strict';varundici=require('undici');// Require the necessary discord.js classesconst{ Client, Events, GatewayIntentBits}=require('discord.js');const{ token}=require('./config.json');// Create a new client instanceconstclient=newClient({intents:[GatewayIntentBits.Guilds],rest:{agent:newundici.ProxyAgent(`http://127.0.0.1:7890`)}});// When the client is ready, run this code (only once)// We use 'c' for the event parameter to keep it separate from the already defined 'client'client.once(Events.ClientReady,c=>{console.log(`Ready! Logged in as${c.user.tag}`);});// Log in to Discord with your client's tokenclient.login(token).catch(error=>{console.error(`An error occurred while logging in:${error.message}`);});

image

This is the proxy port.

image

You must be logged in to vote
0 replies
Comment options

Qjuh
May 3, 2023
Collaborator

The ProxyAgent you pass is for the REST API connection. Your error is from establishing the WebSocket Gateway connection failing. So not related.

You must be logged in to vote
0 replies
Comment options

Hi @sukbearsuwu,

Lets try fix your client.login() issue.

How is your config.json file? Can you send it not showing your token

it sould be like this:

{    "token": "YOUR_TOKEN_HERE"}
You must be logged in to vote
0 replies
Comment options

I have same issue,how can i resolve this problem ? i can run my service successfully on local,but deploy on linux with network proxy, the terminal throw above the error

You must be logged in to vote
1 reply
@Qjuh
Comment options

QjuhMay 14, 2023
Collaborator

You need to configure your host to correctly use the proxy in its network configuration then, not a djs issue.

Comment options

I have the same problem. Has the host solved it

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
5 participants
@sukbearai@Jfs007@MiguelSantos96@Qjuh@bao-io
Converted from issue

This discussion was converted from issue #9498 on May 03, 2023 13:28.


[8]ページ先頭

©2009-2025 Movatter.jp