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

Discord API Update #6

Open
Neko308 opened this issue Oct 29, 2020 · 0 comments
Open

Discord API Update #6

Neko308 opened this issue Oct 29, 2020 · 0 comments

Comments

@Neko308
Copy link

Neko308 commented Oct 29, 2020

Hi,

I'm totally new to github and have near-zero programming experience in developer role so I'm posting here.

A recent change in the Discord API breaks the swg-discord-bot. It causes server.members.get(message.author.id).displayName to return "undefined". When I debugged, I found that the bot could only see itself when it pulled a list of members from the server/guild. I learned that the discord bot now needs to define its Intent in order to access members information.

Step 1: Go to the Discord Developer Portal, Select your swg-discord-bot App, Go to the Bot tab, turn on the switch for "Server Members Intent", and save the setting.

Step 2: Update the discord.js package using npm update discord.js

Step 3: Modify the discordbot.js source to declare the Intent

  1. Define a const "Intents" right after "Discord"
    const Discord = require('discord.js');
    const Intents = require('discord.js');

  2. Change the construct line to declare the Intent of the bot (I used Intents.ALL just to make it easy)
    //client = new Discord.Client();
    client = new Discord.Client({ws:{intents:Intents.ALL}});

I got the information about the Intents at the Discord.js Guide: https://discordjs.guide/popular-topics/intents.html#enabling-intents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant