These are example bots for DSharpPlus library.
They are basic bots which are meant to introduce you to various aspects of the DSharpPlus library.
- Example 1: Introduces very basic bot skeleton. The bot simply connects to guilds, and prints some information to console.
- Example 2: Introduces CommandsNext. This bot also responds to several commands, as well as presents several CNext concepts and examples of use.
- Example 3: Introduces Interactivity. This bot has several commands that interact with the user in different ways. Presented are several examples of use.
- Example 4: Introduces VoiceNext. This bot has the ability to connect to voice channels and play music in them. Presented is a simple bot that broadcasts audio from specified file in a queued manner.
- Example 5: Demonstrates a bot with a Windows Forms UI. Presented is a way to run a bot without deadlocking the entire application, as well as properly dispatching the events to the UI.
- Example 6: Demonstrates a bot with a Windows Presentation Foundation (WPF) UI. Presented is a way to run a bot without deadlocking the entire application, as well as properly dispatching the events to the UI.
These projects were made using Visual Studio 2017, and they target .NET Core 3.1. You will need one of the following to open and build the projects:
- Visual Studio 2019 Community with .NET Core cross-platform development installed.
- Visual Studio Code with C# extension.
You will also need to install .NET Core 3.1 SDK in both cases.
In order to run the bots, you must first create an application for them, build the bots, then configure them.
- Go to Applications page on Discord Developer portal.
- Press the New Application button.
- New Application page will open. Enter your bot's name in the name field.
- When you're done, press the create button.
- When the app is created, jump to the bot section and press the add bot button.
- Once this is done, you will need to copy the bot's token. Under app bot user, there's a token field, press copy the resulting value.
- Open the project, select the startup bot, and compile it.
- Go to
<project path>
, and copy theconfig.json
file there. - Now go to
DSPlus.Examples.<language>.Ex0n
(wheren
is the selected example), paste that file here. - Open it with Notepad. Replace the placeholder values (do not remove the quotes) with your actual token and command prefix. Save it.
- Our bot is now configured, but we need to add it to our server first.
- Go back to your app page, and copy your bot's client ID.
- Go to
https://discordapp.com/oauth2/authorize?client_id=your_app_id_here&scope=bot&permissions=0
. - On the page, select your server (1), and press authorize (2).
- Verify that you are not a robot and you're done! You can now run the bot!
- Go back to the IDE and hit Debug.
- Congratulations! Your bot is running!
Windows Forms (WinForms), Windows Presentation Foundation (WPF), and Universal Windows Platform (UWP) are not officially supported ways of running your bot. These examples exist for educational purposes only.
We will not provide support for running bots through WinForms, WPF, UWP, or any other UI framework, especially non-asynchronous one.
If you require a non-console or non-Discord interface for your bot, consider an ASP.NET or ASP.NET Core application, as these at least offer support for asynchronous code.
You might want to play around with the examples, perhaps modify them a bit.
You can find the documentation for DSharpPlus over here.
If you want to get more help, join the unofficial Discord API server, and look for #dotnet_dsharpplus channel.