Better support for bot accounts

This commit is contained in:
Master Kwoth 2016-04-14 22:09:19 +02:00
parent 2784920fa8
commit fb5a52de3a
3 changed files with 32 additions and 19 deletions

View File

@ -50,11 +50,12 @@ namespace NadekoBot.Commands
var com = NadekoBot.Client.GetService<CommandService>().AllCommands
.FirstOrDefault(c => c.Text.ToLower().Equals(comToFind));
if (com != null)
await e.Channel.SendMessage($"`Help for '{com.Text}:'` **{com.Description}**");
await e.Channel.SendMessage($"`Help for '{com.Text}':` **{com.Description}**");
});
};
public static string HelpString => $"You can use `{NadekoBot.Config.CommandPrefixes.Help}modules` command to see a list of all modules.\n" +
public static string HelpString => NadekoBot.IsBot ? $"To invite {NadekoBot.Client.CurrentUser.Name} to your server, go here: <>\n" : "" +
$"You can use `{NadekoBot.Config.CommandPrefixes.Help}modules` command to see a list of all modules.\n" +
$"You can use `{NadekoBot.Config.CommandPrefixes.Help}commands ModuleName`" +
$" (for example `{NadekoBot.Config.CommandPrefixes.Help}commands Administration`) to see a list of all of the commands in that module.\n" +
$"For a specific command help, use `{NadekoBot.Config.CommandPrefixes.Help}h \"Command name\"` (for example `-h \"!m q\"`)\n" +
@ -121,11 +122,11 @@ Version: `{NadekoStats.Instance.BotVersion}`";
.Do(async e =>
{
await e.Channel.SendMessage(
@"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `nadekodiscordbot@gmail.com`
$@"I've created a **paypal** email for nadeko, so if you wish to support the project, you can send your donations to `nadekodiscordbot@gmail.com`
Don't forget to leave your discord name or id in the message, so that I can reward people who help out.
You can join nadekobot server by simply private messaging NadekoBot, and you will get an invite.
You can join nadekobot server by typing {Module.Prefix}h and you will get an invite in a private message.
*If you want to support in some other way or on a different platform, please message me there*"
*If you want to support in some other way or on a different platform, please message me*"
);
});
}

View File

@ -1,27 +1,33 @@
using System.Linq;
using Discord.Commands;
using Discord.Modules;
using Discord.Commands;
using NadekoBot.Commands;
using NadekoBot.Extensions;
using System.Linq;
namespace NadekoBot.Modules {
internal class Help : DiscordModule {
namespace NadekoBot.Modules
{
internal class Help : DiscordModule
{
public Help() {
public Help()
{
commands.Add(new HelpCommand(this));
}
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Help;
public override void Install(ModuleManager manager) {
manager.CreateCommands("", cgb => {
public override void Install(ModuleManager manager)
{
manager.CreateCommands("", cgb =>
{
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
commands.ForEach(com => com.Init(cgb));
cgb.CreateCommand(Prefix + "modules")
.Alias(".modules")
.Description("List all bot modules.")
.Do(async e => {
.Do(async e =>
{
await e.Channel.SendMessage("`List of modules:` \n• " + string.Join("\n• ", NadekoBot.Client.GetService<ModuleService>().Modules.Select(m => m.Name)));
});
@ -29,11 +35,13 @@ namespace NadekoBot.Modules {
.Alias(".commands")
.Description("List all of the bot's commands from a certain module.")
.Parameter("module", ParameterType.Unparsed)
.Do(async e => {
.Do(async e =>
{
var cmds = NadekoBot.Client.GetService<CommandService>().AllCommands
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
if (!cmdsArray.Any()) {
if (!cmdsArray.Any())
{
await e.Channel.SendMessage("That module does not exist.");
return;
}

View File

@ -28,6 +28,7 @@ namespace NadekoBot
public static LocalizedStrings Locale { get; set; } = new LocalizedStrings();
public static string BotMention { get; set; } = "";
public static bool Ready { get; set; } = false;
public static bool IsBot { get; set; } = false;
private static Channel OwnerPrivateChannel { get; set; }
@ -90,7 +91,7 @@ namespace NadekoBot
}
//if password is not entered, prompt for password
if (string.IsNullOrWhiteSpace(Creds.Password) && !string.IsNullOrWhiteSpace(Creds.Token))
if (string.IsNullOrWhiteSpace(Creds.Password) && string.IsNullOrWhiteSpace(Creds.Token))
{
Console.WriteLine("Password blank. Please enter your password:\n");
Creds.Password = Console.ReadLine();
@ -185,7 +186,11 @@ namespace NadekoBot
if (string.IsNullOrWhiteSpace(Creds.Token))
await Client.Connect(Creds.Username, Creds.Password);
else
{
await Client.Connect(Creds.Token);
IsBot = true;
}
}
catch (Exception ex)
{
@ -197,6 +202,7 @@ namespace NadekoBot
Console.ReadKey();
return;
}
Console.WriteLine("-----------------");
Console.WriteLine(await NadekoStats.Instance.GetStats());
Console.WriteLine("-----------------");
@ -218,8 +224,6 @@ namespace NadekoBot
if (string.IsNullOrWhiteSpace(request.Content))
e.Cancel = true;
};
//await Task.Delay(90000);
Classes.Permissions.PermissionsHandler.Initialize();
NadekoBot.Ready = true;
});
@ -245,7 +249,7 @@ namespace NadekoBot
if (ConfigHandler.IsBlackListed(e))
return;
if (!NadekoBot.Config.DontJoinServers)
if (!NadekoBot.Config.DontJoinServers && !IsBot)
{
try
{