Discord Visual Studio Code
Extension for Visual Studio Code - Update your discord status with a rich presence. I am a new programmer and I don't really understand that much in node.js or any of these things. My main problem isn't a code bug itself rather not being able to install discord.js in Visual Studio Code. The command I tried to run is 'npm install discord.js' in the terminal and in cmd but both didn't work for me. Open up your preferred code editor (whether it be Visual Studio Code (opens new window), Atom (opens new window), Sublime Text (opens new window), or any other editor of your choice) and create a new file. If you're brand new and aren't sure what to use, go with Visual Studio Code. How do I install discord.js on Visual Studio Code? Ask Question Asked 20 days ago. Active 15 days ago. Viewed 53 times -3. I tried installing discord.js on my.
We're finally getting to the exciting parts! Since your bot is in your server now, the next step is to start coding and get it online!
# Creating the bot file
Open up your preferred code editor (whether it be Visual Studio Code(opens new window), Atom(opens new window), Sublime Text(opens new window), or any other editor of your choice) and create a new file. If you're brand new and aren't sure what to use, go with Visual Studio Code.
We suggest that you save the file as index.js
, but you may name it whatever you wish, as long as it ends with .js
.
TIP
You can quickly create a new file using the Ctrl + N
shortcut on your keyboard and then using Ctrl + S
to save the file.
# Logging in to Discord
Once you've created a new file, do a quick check to see if you have everything setup correctly. Copy & paste the following code into your file and save it. Don't worry if you don't understand it right away—we explain more in-depth after this.
Head back to your console window, type in node your-file-name.js
, and press enter. If you see the Ready!
message after a few seconds, you're good to go! If not, try going back a few steps and make sure you followed everything correctly.
TIP
Don't feel like typing the file name each time? Open up your package.json
file, look for something like 'main': 'index.js'
, and change 'index.js'
to whatever your file name is. After saving, you can run the node .
shortcut in your console to start the process!
# Start-up code explained
Here's the same code with comments, so it's easier to understand what's going on.
Although it's not a lot, it's good to know what each bit of your code does. But, as it currently is, this won't do anything. You probably want to add some commands that run whenever someone sends a specific message, right? Let's get started on that, then!
# Listening for messages
First, make sure to close the process in your console. You can do so by pressing Ctrl + C
inside the console. Go back to your code editor and add the following piece of code above the client.login()
line.
Notice how the code uses .on
rather than .once
like in the ready event. This means that it can trigger multiple times. Save the file, go back to your console, and start the process up again. Whenever a message is sent inside a channel your bot can access, the console will log the message's content. Go ahead and test it out!
TIP
Inside your console, you can press the up arrow on your keyboard to bring up the latest commands you've run. Pressing Up
and then Enter
after closing the process is a convenient, quick way to start it up again (instead of typing out the name each time).
# Replying to messages
Logging to the console is great and all, but it doesn't provide any feedback for the end-user. Let's create a basic ping/pong command before you move on to making real commands. Remove the console.log(message.content)
line from your code and replace it with the following:
Restart your bot and then send !ping
to a channel your bot has access to. If all goes well, you should see something like this:
You've successfully created your first Discord bot command! Exciting stuff, isn't it? This is only the beginning, so let's move on to making some more commands.
# Resulting code
If you want to compare your code to the code we've constructed so far, you can review it over on the GitHub repository here (opens new window).
Display your current project on vscode in discord with Rich Presence
Features
Show up an icon for the current language in the rich embed
Disable/enable for each workspace
Strings entirely modifiable
Removed registery writing
Install
Install the extension. The extension needs Discord to be launched.
Facultative: Add Visual Studio Code as 'Game' on Discord. If you don't add it, it will still display 'Playing Visual Studio Code' when you close it.
Changing the default icons
To change the default language icons, see #12
Extension Settings
This extension contributes the following settings:
How To Make A Discord Bot [Ultimate Guide For 2020]
discord.enable
: enable/disable this extensiondiscord.showDebug
: Show the debugging icon in the rich presence when debuggingdiscord.debugIconText
: The small image debug text when debuggingdiscord.showElapsedTime
: Show/hide the time that has elapsed since you started editing a certain filediscord.clientID
: the client ID used by discord-rpcdiscord.state
: The dicord rich presence state. Default toWorking on {projectName}
.{projectName}
:workspace namediscord.details
: The discord rpc details. Default toEditing {filename}
. {filename}: filename, {language} : language id.discord.vscodeIconText
: The small icon hint (smallImageText). Default to Visual Studio Codediscord.languageIconText
: The hint for the language icon (largeImageText). Default to{language}
{language} : language iddiscord.idle
: The default text when there is no editor opened. Default toidle
discord.iconMap
: The iconMap for the filename extensionsdiscord.interval
: The interval time to update the informations in ms. Default to 3000ms
Frequently asked Questions
Can I get banned?
Well, someone already asked for it. I emailed the Discord Team, and that's totally fine, unless you disrespect their Terms and Conditions.
It's not showing on Discord?
Check out if Visual Studio Code is added as game on your Discord client.
License
The source code is licensed under the ISC License.
The icons are licensed under the Creative Commons - ShareAlike (CC BY-SA) license.
Release Notes
0.0.1
Initial release of vscode-discord
0.0.2
Rewritten Discord Register
0.0.3
- Removed Discord Registers for OSs other than Windows.
- Added python support
- Added a VSCode disposable client, to let the Rich Presence reset when the process quit.
1.0.0
First realease
Removed Registry
Added a new option: show debug
1.0.1
Visual Studio Code Discord.py
Better Icon Mapping
Patched time issue
Made elapsed time toggel-able through
discord.showElapsedTime
setting