BotBase 1.1.3

This is a project to create a good discord bot base for everyone wanting a simple way to create a good bot

Install-Package BotBase -Version 1.1.3
dotnet add package BotBase --version 1.1.3
<PackageReference Include="BotBase" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BotBase --version 1.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
  1. Create a DatabaseProvider
// Use these methods to store all the objects in a database
public class MyDatabaseProvider : IDatabaseProvider
{
    // Warning: If GetServer returns null, the library will throw an exception, so make sure it won't return null
    public Server GetServer(ulong id)
    {
        ...
    }

    public Task UpdateServer(Server server)
    {
        ...
    }

    public User GetUser(ulong id)
    {
        ...
    }

    public Task UpdateUser(User user)
    {
        ...
    }
}
  1. Initialize a instance of BotBase
// I recommend you configuring the Configs like you wish and not use this too simplified error handler
var client = new BotBase(new Configuration{Token = "YourBotToken"}, new DiscordSocketConfig(), new CommandServiceConfig(), (context, result) => Console.WriteLine(result.Error), new MyDatabaseProvider());

// This initializes the bot 
var task = client.InitializeAsync();

// Because task will never return to let your bot stay alive, at the end of your initialization you want to await the task
task.Wait();
  1. Create your bot

    • Adding services

        // To add a service, you just need to add the IsService attribute to your service class
        [IsService]
        public class SomeService
        {
        	...
        }
      
    • Adding modules

        // To add a module, you need to inherit CommandBase or CommandBase<TServer, TUser>
        public class SomeModule : CommandBase
        {
        	[Command]
        	public async Task SomeCommand()
        	{
        		...
        	}
        }
      
  2. Extending Server and User

// If you want to extend Server or User you need to create classes inheriting these
public class SomeServer : Server
{
	public string SomeString;
}

public class SomeUser : User
{
	public string SomeString;
}
// Then you need to pass the types into new BotBase
var client = new BotBase<SomeServer, SomeUser>(...);
// But you are not done, not yet
// You need to modify the modules to not inherit CommandBase, but CommandBase<TServer, TUser>
public class SomeModule : CommandBase<SomeServer, SomeUser>
{ 
	...
}
  1. Go to your friends and make them envious about your bot, then tell them you made it with this library and enjoy your bot and stop complaining and reading this shit

  2. If you still got questions, just join my discord server https://discord.gg/7e9Vhzs

  1. Create a DatabaseProvider
// Use these methods to store all the objects in a database
public class MyDatabaseProvider : IDatabaseProvider
{
    // Warning: If GetServer returns null, the library will throw an exception, so make sure it won't return null
    public Server GetServer(ulong id)
    {
        ...
    }

    public Task UpdateServer(Server server)
    {
        ...
    }

    public User GetUser(ulong id)
    {
        ...
    }

    public Task UpdateUser(User user)
    {
        ...
    }
}
  1. Initialize a instance of BotBase
// I recommend you configuring the Configs like you wish and not use this too simplified error handler
var client = new BotBase(new Configuration{Token = "YourBotToken"}, new DiscordSocketConfig(), new CommandServiceConfig(), (context, result) => Console.WriteLine(result.Error), new MyDatabaseProvider());

// This initializes the bot 
var task = client.InitializeAsync();

// Because task will never return to let your bot stay alive, at the end of your initialization you want to await the task
task.Wait();
  1. Create your bot

    • Adding services

        // To add a service, you just need to add the IsService attribute to your service class
        [IsService]
        public class SomeService
        {
        	...
        }
      
    • Adding modules

        // To add a module, you need to inherit CommandBase or CommandBase<TServer, TUser>
        public class SomeModule : CommandBase
        {
        	[Command]
        	public async Task SomeCommand()
        	{
        		...
        	}
        }
      
  2. Extending Server and User

// If you want to extend Server or User you need to create classes inheriting these
public class SomeServer : Server
{
	public string SomeString;
}

public class SomeUser : User
{
	public string SomeString;
}
// Then you need to pass the types into new BotBase
var client = new BotBase<SomeServer, SomeUser>(...);
// But you are not done, not yet
// You need to modify the modules to not inherit CommandBase, but CommandBase<TServer, TUser>
public class SomeModule : CommandBase<SomeServer, SomeUser>
{ 
	...
}
  1. Go to your friends and make them envious about your bot, then tell them you made it with this library and enjoy your bot and stop complaining and reading this shit

  2. If you still got questions, just join my discord server https://discord.gg/7e9Vhzs

Version History

Version Downloads Last updated
1.1.3 179 12/30/2018
1.1.2 112 12/30/2018
1.1.1 130 12/30/2018
1.1.0 131 12/30/2018
1.0.1 135 12/29/2018