Updated Code Samples for compatibility with 0.9; fixed events; fixed rST
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|stub| Commands
|
||||
===============
|
||||
|
||||
The `Discord.Net.Commands`_ package DiscordBotClient extends DiscordClient with support for commands.
|
||||
The `Discord.Net.Commands`_ package extends DiscordClient with a built-in Commands Handler.
|
||||
|
||||
.. _Discord.Net.Commands: https://www.nuget.org/packages/Discord.Net.Commands
|
||||
|
||||
|
||||
@@ -3,21 +3,19 @@ Events
|
||||
|
||||
Usage
|
||||
-----
|
||||
Messages from the Discord server are exposed via events on the DiscordClient class and follow the standard EventHandler<EventArgs> C# pattern.
|
||||
Messages from the Discord server are exposed via events on the DiscordClient class and follow the standard EventHandler<EventArgs> C# pattern.
|
||||
|
||||
.. warning::
|
||||
Note that all synchronous code in an event handler will run on the gateway socket's thread and should be handled as quickly as possible.
|
||||
Note that all synchronous code in an event handler will run on the gateway socket's thread and should be handled as quickly as possible.
|
||||
Using the async-await pattern to let the thread continue immediately is recommended and is demonstrated in the examples below.
|
||||
|
||||
Connection State
|
||||
----------------
|
||||
Ready
|
||||
-----
|
||||
|
||||
Connection Events will be raised when the Connection State of your client changes.
|
||||
The Ready Event is raised only once, when your client finishes processing the READY packet from Discord.
|
||||
|
||||
This has replaced the previous "Connected" event, and indicates that it is safe to begin retrieving users, channels, or servers from the cache.
|
||||
|
||||
.. warning::
|
||||
You should not use DiscordClient.Connected to run code when your client first connects to Discord.
|
||||
If you lose connection and automatically reconnect, this code will be ran again, which may lead to unexpected behavior.
|
||||
|
||||
Messages
|
||||
--------
|
||||
|
||||
@@ -26,7 +24,7 @@ Messages
|
||||
|
||||
Example of MessageReceived:
|
||||
|
||||
.. code-block:: c#
|
||||
.. code-block:: csharp6
|
||||
|
||||
// (Preface: Echo Bots are discouraged, make sure your bot is not running in a public server if you use them)
|
||||
|
||||
@@ -56,7 +54,7 @@ There are several user events:
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: c#
|
||||
.. code-block:: csharp6
|
||||
|
||||
// Register a Hook into the UserBanned event using a Lambda
|
||||
_client.UserBanned += async (s, e) => {
|
||||
|
||||
@@ -2,12 +2,12 @@ Logging
|
||||
=======
|
||||
|
||||
Discord.Net will log all of its events/exceptions using a built-in LogManager.
|
||||
This LogManager can be accessed through DiscordClient.Log
|
||||
This LogManager can be accessed through ``DiscordClient.Log``
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To handle Log Messages through Discord.Net's Logger, you must hook into the Log.Message<LogMessageEventArgs> Event.
|
||||
To handle Log Messages through Discord.Net's Logger, you must hook into the ``Log.Message<LogMessageEventArgs>`` Event.
|
||||
|
||||
The LogManager does not provide a string-based result for the message, you must put your own message format together using the data provided through LogMessageEventArgs
|
||||
See the Example for a snippet of logging.
|
||||
@@ -17,19 +17,25 @@ Logging Your Own Data
|
||||
|
||||
The LogManager included in Discord.Net can also be used to log your own messages.
|
||||
|
||||
You can use DiscordClient.Log.Log(LogSeverity, Source, Message, Exception), or one of the shortcut helpers, to log data.
|
||||
You can use ``DiscordClient.Log.Log(LogSeverity, Source, Message, [Exception])``, or one of the shortcut helpers, to log data.
|
||||
|
||||
Example:
|
||||
.. code-block:: c#
|
||||
|
||||
.. code-block:: csharp6
|
||||
|
||||
_client.MessageReceived += async (s, e) {
|
||||
// Log a new Message with Severity Info, Sourced from 'MessageReceived', with the Message Contents.
|
||||
_client.Log.Info("MessageReceived", e.Message.Text, null);
|
||||
};
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
Starting in Discord.Net 1.0, you will not be able to log your own messages. You will need to create your own Logging manager, or use a pre-existing one.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. literalinclude:: /samples/logging.cs
|
||||
:language: c#
|
||||
:language: csharp6
|
||||
:tab-width: 2
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Permissions
|
||||
===========
|
||||
|stub| Permissions
|
||||
==================
|
||||
|
||||
|outdated|
|
||||
|
||||
There are two types of permissions: *Channel Permissions* and *Server Permissions*.
|
||||
|
||||
@@ -61,6 +63,7 @@ KickMembers Server Kick users from the server. They can still rejoi
|
||||
ManageRoles Server Manage roles on the server, and their permissions.
|
||||
ManageChannels Server Manage channels that exist on the server (add, remove them)
|
||||
ManageServer Server Manage the server settings.
|
||||
======================= ======= ==============
|
||||
|
||||
Roles
|
||||
-----
|
||||
|
||||
@@ -10,7 +10,7 @@ You can create Channels, Invites, and Roles on a server using the CreateChannel,
|
||||
|
||||
You may also edit a server's name, icon, and region.
|
||||
|
||||
.. code-block:: c#
|
||||
.. code-block:: csharp6
|
||||
|
||||
// Create a Channel and retrieve the Channel object
|
||||
var _channel = await _server.CreateChannel("announcements", ChannelType.Text);
|
||||
|
||||
@@ -6,7 +6,7 @@ Banning
|
||||
|
||||
To ban a user, invoke the Ban function on a Server object.
|
||||
|
||||
.. code-block:: c#
|
||||
.. code-block:: csharp6
|
||||
|
||||
_server.Ban(_user, 30);
|
||||
|
||||
@@ -17,6 +17,6 @@ Kicking
|
||||
|
||||
To kick a user, invoke the Kick function on the User.
|
||||
|
||||
.. code-block:: c#
|
||||
.. code-block:: csharp6
|
||||
|
||||
_user.Kick();
|
||||
|
||||
@@ -10,4 +10,4 @@ Multi-Server Broadcasting
|
||||
-------------------------
|
||||
|
||||
Receiving
|
||||
---------
|
||||
---------
|
||||
|
||||
Reference in New Issue
Block a user