From 24729022a6c1f9130645ddabfb36895d40800501 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Thu, 26 Nov 2015 20:55:48 +0100 Subject: [PATCH] Updated docs a bit --- docs/getting_started.rst | 14 +++++--- docs/samples/command.cs | 26 ++++++--------- docs/samples/command_group.cs | 41 ++++++++++++------------ docs/samples/command_service_creation.cs | 9 ++++++ 4 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 docs/samples/command_service_creation.cs diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 4ebc4f841..1e8ee492e 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -4,7 +4,7 @@ Getting Started Requirements ------------ -Discord.Net currently requires logging in with a claimed account - anonymous logins are not supported. You can `register for a Discord account here`. +Discord.Net currently requires logging in with a claimed account - anonymous logins are not supported. You can `register for a Discord account here`_. New accounts are also useless when not connected to a server, so you should create an invite code for whatever server you intend to test on using the official Discord client. @@ -17,12 +17,16 @@ You can get Discord.Net from NuGet: * `Discord.Net`_ * `Discord.Net.Commands`_ +* `Discord.Net.Modules`_ + +If you have trouble installing from NuGet, try installing dependencies manually. You can also pull the latest source from `GitHub`_ -.. _Discord.Net: https://discordapp.com/register -.. _Discord.Net.Commands: https://discordapp.com/register -.. _GitHub: https://github.com/RogueException/Discord.Net/> +.. _Discord.Net: https://www.nuget.org/packages/Discord.Net/0.8.1-beta2 +.. _Discord.Net.Commands: https://www.nuget.org/packages/Discord.Net.Commands/0.8.1-beta2 +.. _Discord.Net.Modules: https://www.nuget.org/packages/Discord.Net.Modules/0.8.1-beta2 +.. _GitHub: https://github.com/RogueException/Discord.Net/ Async ----- @@ -39,4 +43,4 @@ Example .. literalinclude:: samples/getting_started.cs :language: csharp6 - :tab-width: 2 \ No newline at end of file + :tab-width: 2 diff --git a/docs/samples/command.cs b/docs/samples/command.cs index 2dfb8e549..d32e216c3 100644 --- a/docs/samples/command.cs +++ b/docs/samples/command.cs @@ -1,16 +1,10 @@ -public enum Permissions -{ - User, - Moderator, - Admin -} - -//Usage: say [text] -client.CreateCommand("say") - .ArgsEqual(1) - .MinPermissions((int)Permissions.User) - .Do(async e => - { - string msg = Format.Normal(e.CommandText); - await _client.SendMessage(e.Channel, msg); - }); \ No newline at end of file +//Since we have setup our CommandChar to be '~', we will run this command by typing ~greet +commands.CreateCommand("greet") //create command greet + .Alias(new string[] { "gr", "hi" }) //add 2 aliases, so it can be run with ~gr and ~hi + .Description("Greets a person.") //add description, it will be shown when ~help is used + .Parameter("GreetedPerson", ParameterType.Required) //as an argument, we have a person we want to greet + .Do(async e => + { + await client.SendMessage(e.Channel, e.User.Name + " greets " + e.GetArg("GreetedPerson")); + //sends a message to channel with the given text + }); \ No newline at end of file diff --git a/docs/samples/command_group.cs b/docs/samples/command_group.cs index b49b87d94..5610723be 100644 --- a/docs/samples/command_group.cs +++ b/docs/samples/command_group.cs @@ -1,20 +1,21 @@ -client.CreateCommandGroup("invites", invites => -{ - invites.DefaultMinPermissions((int)Permissions.Admin); - - //Usage: invites accept [inviteCode] - invites.CreateCommand("accept") - .ArgsEqual(1) - .Do(async e => - { - try - { - await _client.AcceptInvite(e.Args[0]); - await _client.SendMessage(e.Channel, "Invite \"" + e.Args[0] + "\" accepted."); - } - catch (HttpException ex) - { - await _client.SendMessage(e.Channel, "Error: " + ex.Message); - } - }); -}); \ No newline at end of file +//we would run our commands with ~do greet X and ~do bye X +commands.CreateGroup("do", cgb => + { + cgb.CreateCommand("greet") + .Alias(new string[] { "gr", "hi" }) + .Description("Greets a person.") + .Parameter("GreetedPerson", ParameterType.Required) + .Do(async e => + { + await client.SendMessage(e.Channel, e.User.Name + " greets " + e.GetArg("GreetedPerson")); + }); + + cgb.CreateCommand("bye") + .Alias(new string[] { "bb", "gb" }) + .Description("Greets a person.") + .Parameter("GreetedPerson", ParameterType.Required) + .Do(async e => + { + await client.SendMessage(e.Channel, e.User.Name + " says goodbye to " + e.GetArg("GreetedPerson")); + }); + }); \ No newline at end of file diff --git a/docs/samples/command_service_creation.cs b/docs/samples/command_service_creation.cs new file mode 100644 index 000000000..013619ff5 --- /dev/null +++ b/docs/samples/command_service_creation.cs @@ -0,0 +1,9 @@ +//create command service +var commandService = new CommandService(new CommandServiceConfig +{ + CommandChar = '~', // prefix char for commands + HelpMode = HelpMode.Public +}); + +//add command service +var commands = client.AddService(commandService); \ No newline at end of file