Help Command - koreanpanda345/Discord_Net_Example GitHub Wiki

Help Command

This tutorial will talk about making a Dynamic help command using the command manager.

What does Dynamic and Fixed mean?

This is something a lot of people already know what the terms means, but what does it really mean when we talk about it in a programming aspect? The idea of something Dynamic means to be able to change in size. Fixed is when something has a limit of size. Crazy, right? So you maybe thinking when would you use Dynamic, and Fixed.

When should you use Dynamic

You should something that is dynamic if you know that there is no set size. example would be the amount of commands we will add to the bot.

When should you use Fixed

You should use something that is fixed if you know what the limit of the size you want it to be. example is that we know that we only want to have 3 cookies, nothing more, and nothing less.

So what do we mean when we say a Dynamic Help Command?

A dynamic help command is a help command that changes automatically based on the amount of commands we have on the bot. this limits the amount of times we have to be in the help command, and it will allows us to have shorter code ( I sure do love short code)

Let's start with the help command.

Before we start make sure you check the Command Manger page, as this will only work with that kind of command manager.

lets make a new file in the Commands Folder in the Core folder.

By now, you should have a good idea of how to set up the command, it should look something like this:

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Discord;
using Disocrd.Commands;

namespace <Project_Name>.Core.Commands
{
   public class Help : ModuleBase<SocketCommandContext>
    {

    }
}

(<Project_Name> is your project name)

cool, now we will do something different, we will be making a constructor, but before that we need to define a variable:

private readonly CommandService service;

We will be grabbing the command service from the Main File.

next let's make the constructor

public Help(CommandService service)
{
    this.service = service;
}

Cool. We will need this constructor later, for now lets work on making the command.

[Command("help")]
[Alias("command", "commands")]
[Summary("Displays info about a command or a list of my commands")]
public async Task HelpCommand([Remainder] string command = "!")
{

}