Logging In
The most crucial step - logging in to Discord's bot API
Last updated
The most crucial step - logging in to Discord's bot API
Last updated
The first step to talk to Discord is always logging in.
In your Bot.swift
(or equivalent) file, you'll need to add the following line to your main()
function:
As simple as that: if you run your app now (assuming you've added your token correctly), it'll attempt to connect to the Discord Gateway and set the REST API handler, ready for API requests. You should see something like the following at the bottom of your console:
However, most of the time you'd like to listen to some events, which can be done by adding the code below to your main()
function, before the call to bot.login()
:
Rerun your app, and you should see that message printed out in the console shortly after!