Craze
Alt + F4
- Messages
- 229
- Reaction score
- 163
- Points
- 903
[[ Please move this thread to the Discord section, once we get one ]]
Requirements:
Visual Studio
Small knowledge of C#
Nuget Package Manager (Look below for how to get)
Ok, firstly make sure you have Visual Studio. Also, you need "Nuget Package Manager" for it.
If you don't have "Nuget Package Manager", Look up how to get it for visual studio.
Step 1 - Setting up the project
Step 2 - Setting up Bot
Step 3 - Commands
Step 4 - Adding the bot to a server.
If you have any questions or suggestions, please tell me in the comments!
Requirements:
Visual Studio
Small knowledge of C#
Nuget Package Manager (Look below for how to get)
Ok, firstly make sure you have Visual Studio. Also, you need "Nuget Package Manager" for it.
If you don't have "Nuget Package Manager", Look up how to get it for visual studio.
Step 1 - Setting up the project
Firstly, make a new Visual C# Console application. And the install Discord.NET
To install Discord.NET, go to Tools and the hover over Nuget Package Manager.
Click "Manage NuGet Packages for Solution..."
After that, click Settings, in the bottom left (of the new tab). Make sure nuget.org is checked.
When it's checked, press OK.
In the bar at the left, click "nuget.org". There should be a search bar in the top right. Search "Discord".
Click Discord.Net (Should be at the top).
(Yours shouldn't be ticked). Click install. It should come up with an agreement, a few seconds after, accept it. Once it's downloaded, The API should be working!
To install Discord.NET, go to Tools and the hover over Nuget Package Manager.
Click "Manage NuGet Packages for Solution..."
After that, click Settings, in the bottom left (of the new tab). Make sure nuget.org is checked.
When it's checked, press OK.
In the bar at the left, click "nuget.org". There should be a search bar in the top right. Search "Discord".
Click Discord.Net (Should be at the top).
(Yours shouldn't be ticked). Click install. It should come up with an agreement, a few seconds after, accept it. Once it's downloaded, The API should be working!
Step 2 - Setting up Bot
Firstly, go here and create a new application.
Name it whatever you want. After that, go to the bottom and click create application.
Once that's done, You should see "Create bot user" Click it and you've setup the discord side of your bot!
Now, it's time for some scripting! You can do whatever you want with your console application, we will just be loading the bot, but you can do colours, text, console title, etc.
In your main function, make this:
This is used for controlling your Bot. It is a variable.
Now a few lines after that, add this:
Go to your bots discord page. It should be here
Click on your bot and scroll down to find token. It should say "Click to reveal" next to it. Click it. And then paste that token where it says YOUR TOKEN HERE in your script.
Your main function should look a bit like this (without the red lines)
Well done, your bot is all setup!
Name it whatever you want. After that, go to the bottom and click create application.
Once that's done, You should see "Create bot user" Click it and you've setup the discord side of your bot!
Now, it's time for some scripting! You can do whatever you want with your console application, we will just be loading the bot, but you can do colours, text, console title, etc.
In your main function, make this:
Code:
var bot = new Discord.DiscordClient();
Now a few lines after that, add this:
Code:
bot.ExecuteAndWait(async () =>
{
await bot.Connect("YOUR TOKEN HERE");
});
Click on your bot and scroll down to find token. It should say "Click to reveal" next to it. Click it. And then paste that token where it says YOUR TOKEN HERE in your script.
Your main function should look a bit like this (without the red lines)
Well done, your bot is all setup!
Step 3 - Commands
Above this:
Add this:
Once you've done that, add this function:
Make sure it is outside of your main function!
Now, it's time to add commands.
Here are some examples:
Make sure they go in bot_MessageReceived.
and, if you type e and then a dot, you'll get a list of things you can do!
Code:
bot.ExecuteAndWait(async () =>
{
await bot.Connect("YOUR TOKEN HERE");
});
Code:
bot.MessageReceived += bot_MessageReceived;
Code:
static void bot_MessageReceived(object sender, Discord.MessageEventArgs e)
{
}
Now, it's time to add commands.
Here are some examples:
Code:
if(e.Message.RawText.StartsWith("Your Command"))
{
e.Channel.SendMessage(e.User.Mention + "Your reply");
}
else if(e.Message.RawText.StartsWith("Your 2nd Command"))
{
e.User.SendMessage("Direct Messaging");
}
and, if you type e and then a dot, you'll get a list of things you can do!
Step 4 - Adding the bot to a server.
If you have any questions or suggestions, please tell me in the comments!
Last edited: