Port 'Getting Started' from Old Docs
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
|
||||
# PLACEHOLDER
|
||||
TODO: Add .NET projects to *src* folder and run `docfx` to generate a **REAL** *API Documentation*!
|
||||
# API Documentation
|
||||
|
||||
This is where you will find documentation for all members and objects in Discord.Net
|
||||
|
||||
**TODO:** Think of something useful to put on this page.
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
# Add your introductions here!
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
- name: Introduction
|
||||
href: intro.md
|
||||
@@ -28,8 +28,8 @@
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"articles/**.md",
|
||||
"articles/**/toc.yml",
|
||||
"guides/**.md",
|
||||
"guides/**/toc.yml",
|
||||
"toc.yml",
|
||||
"*.md"
|
||||
],
|
||||
|
||||
38
docs/guides/intro.md
Normal file
38
docs/guides/intro.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Getting Started
|
||||
---
|
||||
|
||||
# Getting Started
|
||||
|
||||
## Requirements
|
||||
|
||||
Discord.Net supports logging in with all variations of Discord Accounts, however the Discord API reccomends using a `Bot Account`.
|
||||
|
||||
You may [register a bot account here](https://discordapp.com/developers/applications/me).
|
||||
|
||||
Bot accounts must be added to a server, you must use the [OAuth 2 Flow](https://discordapp.com/developers/docs/topics/oauth2#adding-bots-to-guilds) to add them to servers.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install Discord.Net 1.0 from our [MyGet Feed](https://www.myget.org/feed/Packages/discord-net).
|
||||
|
||||
You may add the MyGet feed to Visual Studio directly from `https://www.myget.org/F/discord-net/api/v3/index.json`.
|
||||
|
||||
You can also pull the latest source from [GitHub](https://github.com/RogueException/Discord.Net).
|
||||
|
||||
>[!WARNING]
|
||||
>The versions of Discord.Net on NuGet are behind the versions this documentation is written for.
|
||||
|
||||
## Async
|
||||
|
||||
Discord.Net uses C# tasks extensiely - nearly all operations return one. It is highly reccomended these tasks be awaited whenever possible. To do so requires the calling method to be marked as async, which can be problematic in a console application. An example of how to get around this is provided below.
|
||||
|
||||
For more information, go to [MSDN's Async-Await section.](https://msdn.microsoft.com/en-us/library/hh191443.aspx)
|
||||
|
||||
## First Steps
|
||||
|
||||
[!code-csharp[Main](samples/first-steps.cs)]
|
||||
|
||||
>[!NOTE]
|
||||
>In previous versions of Discord.Net, you had to hook into the `Ready` and `GuildAvailable` events to determine when your client was ready for use.
|
||||
>In 1.0, the [ConnectAsync](xref:Discord.DiscordSocketClient.ConnectAsync) method will automatically wait for the Ready event, and for all guilds to stream. To avoid this, pass `false` into `ConnectAsync`.
|
||||
34
docs/guides/samples/first-steps.cs
Normal file
34
docs/guides/samples/first-steps.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Discord;
|
||||
|
||||
class Program
|
||||
{
|
||||
// Convert our sync-main to an async main method
|
||||
static void Main(string[] args) => new Program().Run().GetAwaiter().GetResult();
|
||||
|
||||
// Create a DiscordClient with WebSocket support
|
||||
private DiscordSocketClient client;
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
client = new DiscordSocketClient();
|
||||
|
||||
// Place the token of your bot account here
|
||||
string token = "aaabbbccc";
|
||||
|
||||
// Hook into the MessageReceived event on DiscordSocketClient
|
||||
client.MessageReceived += async (message) =>
|
||||
{ // Check to see if the Message Content is "!ping"
|
||||
if (message.Content == "!ping")
|
||||
// Send 'pong' back to the channel the message was sent in
|
||||
await message.Channel.SendMessageAsync("pong");
|
||||
};
|
||||
|
||||
// Configure the client to use a Bot token, and use our token
|
||||
await client.LoginAsync(TokenType.Bot, token);
|
||||
// Connect the client to Discord's gateway
|
||||
await client.ConnectAsync();
|
||||
|
||||
// Block this task until the program is exited.
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
}
|
||||
3
docs/guides/toc.yml
Normal file
3
docs/guides/toc.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
- name: Getting Started
|
||||
href: intro.md
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
- name: Articles
|
||||
href: articles/
|
||||
- name: Api Documentation
|
||||
- name: Guides
|
||||
href: guides/
|
||||
- name: API Documentation
|
||||
href: api/
|
||||
homepage: api/index.md
|
||||
|
||||
Reference in New Issue
Block a user