From e251582dc259eeeb056f5cd15730cc9311434322 Mon Sep 17 00:00:00 2001 From: Christopher F Date: Thu, 21 Jul 2016 17:42:39 -0400 Subject: [PATCH] Port 'Getting Started' from Old Docs --- docs/api/index.md | 7 ++++-- docs/articles/intro.md | 2 -- docs/articles/toc.yml | 3 --- docs/docfx.json | 4 ++-- docs/guides/intro.md | 38 ++++++++++++++++++++++++++++++ docs/guides/samples/first-steps.cs | 34 ++++++++++++++++++++++++++ docs/guides/toc.yml | 3 +++ docs/toc.yml | 6 ++--- 8 files changed, 85 insertions(+), 12 deletions(-) delete mode 100644 docs/articles/intro.md delete mode 100644 docs/articles/toc.yml create mode 100644 docs/guides/intro.md create mode 100644 docs/guides/samples/first-steps.cs create mode 100644 docs/guides/toc.yml diff --git a/docs/api/index.md b/docs/api/index.md index 3fcdcb878..3028eef57 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -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. \ No newline at end of file diff --git a/docs/articles/intro.md b/docs/articles/intro.md deleted file mode 100644 index 1a210ba1e..000000000 --- a/docs/articles/intro.md +++ /dev/null @@ -1,2 +0,0 @@ - -# Add your introductions here! diff --git a/docs/articles/toc.yml b/docs/articles/toc.yml deleted file mode 100644 index b79059ca9..000000000 --- a/docs/articles/toc.yml +++ /dev/null @@ -1,3 +0,0 @@ - -- name: Introduction - href: intro.md diff --git a/docs/docfx.json b/docs/docfx.json index f6edf6a06..cd60352b4 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -28,8 +28,8 @@ }, { "files": [ - "articles/**.md", - "articles/**/toc.yml", + "guides/**.md", + "guides/**/toc.yml", "toc.yml", "*.md" ], diff --git a/docs/guides/intro.md b/docs/guides/intro.md new file mode 100644 index 000000000..bb6577a3a --- /dev/null +++ b/docs/guides/intro.md @@ -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`. \ No newline at end of file diff --git a/docs/guides/samples/first-steps.cs b/docs/guides/samples/first-steps.cs new file mode 100644 index 000000000..9db27d2b3 --- /dev/null +++ b/docs/guides/samples/first-steps.cs @@ -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); + } +} \ No newline at end of file diff --git a/docs/guides/toc.yml b/docs/guides/toc.yml new file mode 100644 index 000000000..0c67f96a8 --- /dev/null +++ b/docs/guides/toc.yml @@ -0,0 +1,3 @@ + +- name: Getting Started + href: intro.md diff --git a/docs/toc.yml b/docs/toc.yml index ce4424ad0..c08e708bf 100644 --- a/docs/toc.yml +++ b/docs/toc.yml @@ -1,6 +1,6 @@ -- name: Articles - href: articles/ -- name: Api Documentation +- name: Guides + href: guides/ +- name: API Documentation href: api/ homepage: api/index.md