new commands
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
# Logging in to the Bot
|
||||
Before we start we need to create the .NET application area.
|
||||
|
||||
Create a new .NET console app and add the Valour SDK + DotEnv compatability:
|
||||
Before we start we need to create the .NET application and install the required packages.
|
||||
|
||||
### Setting up the project
|
||||
|
||||
Create a new .NET console app and add the Valour SDK and DotNetEnv:
|
||||
|
||||
```bash
|
||||
dotnet new console -n BasicValourBot
|
||||
@@ -10,19 +13,19 @@ dotnet add package Valour.SDK
|
||||
dotnet add package DotNetEnv
|
||||
```
|
||||
|
||||
### Creating the .env file
|
||||
|
||||
In the root of your Bot folder create a file called `.env`. This file will contain your bot token so **DO NOT** show it to anyone!
|
||||
|
||||
Inside of this file add the following line, replacing the placeholder with your actual token:
|
||||
|
||||
### Firstly we need to create another file!
|
||||
In the root of your Bot folder create another file called ```.env``` this file will contain your bot token so **DO NOT** show it to anyone!
|
||||
<br>
|
||||
Inside of this file we will input the following:
|
||||
<br>
|
||||
```
|
||||
TOKEN=bot-your-bot-token-here
|
||||
```
|
||||
|
||||
### Next we can start coding the bot!
|
||||
### Logging in
|
||||
|
||||
The below code will make a bot and login as that bot account you created.
|
||||
The code below creates a `ValourClient`, loads the token from your `.env` file, and logs in as your bot.
|
||||
|
||||
```c#
|
||||
// Importing the Client SDK and DotEnv.
|
||||
@@ -41,7 +44,7 @@ Env.Load();
|
||||
string token = Environment.GetEnvironmentVariable("TOKEN") ?? string.Empty;
|
||||
|
||||
// Check if the token is valid.
|
||||
if (String.IsNullOrWhiteSpace(token))
|
||||
if (String.IsNullOrWhiteSpace(token))
|
||||
{
|
||||
// The token in your .env file is missing or invalid, make sure you set a valid token!
|
||||
Console.WriteLine($"Token invalid. Please make sure you set a valid token in your .env");
|
||||
@@ -62,13 +65,15 @@ Console.WriteLine($"Logged in as {client.Me.Name} (ID: {client.Me.Id})");
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
```
|
||||
|
||||
Now to run the bot we need to make sure we are inside the root directory of the app and then run:
|
||||
### Running the bot
|
||||
|
||||
Make sure you are inside the root directory of the app and run:
|
||||
|
||||
```bash
|
||||
dotnet run
|
||||
```
|
||||
The bot should then start up and you should see `Logged in as botname (ID: botid)`
|
||||
|
||||
You should then see `Logged in as botname (ID: botid)` in the console.
|
||||
|
||||
##
|
||||
## [The Next step is to Add the bot to a Planet.](2.JoinPlanet.md)
|
||||
---
|
||||
## [The Next step is to Add the bot to a Planet.](2.JoinPlanet.md)
|
||||
|
||||
Reference in New Issue
Block a user