Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What permissions are needed to trigger interactionCreate Event #9703

Closed
bao-io opened this issue Jul 12, 2023 · 10 comments
Closed

What permissions are needed to trigger interactionCreate Event #9703

bao-io opened this issue Jul 12, 2023 · 10 comments

Comments

@bao-io
Copy link

bao-io commented Jul 12, 2023

Which package is this bug report for?

discord.js

Issue description

I have set administrator permissions for the robot and set the following intents. Why am I still unable to receive information about interaction operations

Code sample

const discord = new Client({
      intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent
      ],
      rest: {
        agent: new ProxyAgent(configService.get('app.proxy')),
      },
    });
    discord.on('interactionCreate', (msg) => {
      console.log(msg);
    });

Versions

discord.js: 14.11.0
node: 16.10
system: macos

Issue priority

High (immediate attention needed)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildMessages, MessageContent

I have tested this issue on a development release

No response

@kyranet
Copy link
Member

kyranet commented Jul 12, 2023

The event requires no permissions and is always received unless a HTTP interaction endpoint is set.

Is your bot online? Are you calling client.login();? Can you confirm whether HTTP requests go thru the configured ProxyAgent?

@bao-io
Copy link
Author

bao-io commented Jul 12, 2023

The event requires no permissions and is always received unless a HTTP interaction endpoint is set.

Is your bot online? Are you calling client.login();? Can you confirm whether HTTP requests go thru the configured ProxyAgent?

yeah, i invoke login width my bot token. sorry, i forget to show that. I confirm my http request is correct. i can listen the channel message on messageCreate event. but i am dont't receive the interactionCreate event.
so I would like to confirm again if it is possible to send commands(/info) within the channel to trigger interactionCreate event?

@bao-io
Copy link
Author

bao-io commented Jul 12, 2023

The event requires no permissions and is always received unless a HTTP interaction endpoint is set.

Is your bot online? Are you calling client.login();? Can you confirm whether HTTP requests go thru the configured ProxyAgent?

Or how should I correctly trigger this event?

@monbrey
Copy link
Member

monbrey commented Jul 12, 2023

The event requires no permissions and is always received unless a HTTP interaction endpoint is set.
Is your bot online? Are you calling client.login();? Can you confirm whether HTTP requests go thru the configured ProxyAgent?

yeah, i invoke login width my bot token. sorry, i forget to show that. I confirm my http request is correct. i can listen the channel message on messageCreate event. but i am dont't receive the interactionCreate event. so I would like to confirm again if it is possible to send commands(/info) within the channel to trigger interactionCreate event?

Is it a message, or is it a slash command? It can't be both, and will not trigger both.
Slash Commands must be deployed to Discord in order for users to execute them and trigger interactionCreate.

https://discordjs.guide/creating-your-bot/slash-commands.html#before-you-continue

@bao-io
Copy link
Author

bao-io commented Jul 13, 2023

The event requires no permissions and is always received unless a HTTP interaction endpoint is set.

Is your bot online? Are you calling client.login();? Can you confirm whether HTTP requests go thru the configured ProxyAgent?

yeah, i invoke login width my bot token. sorry, i forget to show that. I confirm my http request is correct. i can listen the channel message on messageCreate event. but i am dont't receive the interactionCreate event. so I would like to confirm again if it is possible to send commands(/info) within the channel to trigger interactionCreate event?

Is it a message, or is it a slash command? It can't be both, and will not trigger both.

Slash Commands must be deployed to Discord in order for users to execute them and trigger interactionCreate.

https://discordjs.guide/creating-your-bot/slash-commands.html#before-you-continue

thank you,your reply give me great understanding of it,but I have a little bit of problem,I join the midjourney in my guild,on one of the channels,Can my robot listen to users using midjournal's built-in commands to trigger interactionCreate event?

@monbrey
Copy link
Member

monbrey commented Jul 13, 2023

You've lost me. Even if your bot was somehow added to the Midjourney server, no, you cannot listen to the commands of a different bot.

@bao-io
Copy link
Author

bao-io commented Jul 13, 2023

You've lost me. Even if your bot was somehow added to the Midjourney server, no, you cannot listen to the commands of a different bot.

so I can only use the user token to create a websocket connection in order to listen midjourney's commands and message,right?

@monbrey
Copy link
Member

monbrey commented Jul 13, 2023

That would be self-botting, which is against Discord's Terms of Service, may result in your account being banned, and will not be supported here.

@monbrey monbrey closed this as completed Jul 13, 2023
@Jiralite Jiralite closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
@suozixie233
Copy link

suozixie233 commented Jul 17, 2023

@LaiBaoYuan Hi, it looks like you have solved the proxy problem? I cannot even log my bot in, but I'm pretty sure that my proxy server is working well, it seems like the proxy does not work well with discord.js. Can you tell me how do you deal with it? Many thanks.

const { Client, Events, GatewayIntentBits} = require('discord.js');
const { token } = require('../config.json');
const { ProxyAgent } = require('undici');

const client = new Client({
	intents: [GatewayIntentBits.Guilds],
	rest: {
		agent: new ProxyAgent('http://127.0.0.1:1080'),
	},
});

client.once(Events.ClientReady, c => {
	console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.login(token);
$ node production/index.js 
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a
 promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.16.0

@bao-io
Copy link
Author

bao-io commented Jul 17, 2023

@LaiBaoYuan Hi, it looks like you have solved the proxy problem? I cannot even log my bot in, but I'm pretty sure that my proxy server is working well, it seems like the proxy does not work well with discord.js. Can you tell me how do you deal with it? Many thanks.

const { Client, Events, GatewayIntentBits} = require('discord.js');
const { token } = require('../config.json');
const { ProxyAgent } = require('undici');

const client = new Client({
	intents: [GatewayIntentBits.Guilds],
	rest: {
		agent: new ProxyAgent('http://127.0.0.1:1080'),
	},
});

client.once(Events.ClientReady, c => {
	console.log(`Ready! Logged in as ${c.user.tag}`);
});

client.login(token);
$ node production/index.js 
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a
 promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.16.0

you can append the catch in the login to see the error detail, I'm not ensure that you have a network problem unless you can show your error detail rather than error without catch.

@discordjs discordjs locked as off-topic and limited conversation to collaborators Jul 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants