CabConModding
Facebook
Twitter
youtube
Discord
Contact us
RSS
Menu
CabConModding
Home
New
Top
Premium
Rules
FAQ - Frequently Asked Questions
Games
Fornite
Call of Duty: Black Ops 3
Clash of Clans
Grand Theft Auto 5
Apex Legends
Assassin’s Creed Origins
Forums
Premium
Latest posts
What's new
Latest posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Log in
Register
What's new
Premium
Latest posts
Menu
Log in
Register
Navigation
Install the app
Install
More options
Dark Theme
Contact us
Close Menu
Forums
Tech Boards
Computer Programming
Source Code & Tutorial
[C#/Tutorial] How to make a Discord Bot (Outdated?)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Craze" data-source="post: 10961" data-attributes="member: 3939"><p>[[ Please move this thread to the Discord section, once we get one ]]</p><p></p><p>Requirements:</p><p>Visual Studio</p><p>Small knowledge of C#</p><p>Nuget Package Manager (Look below for how to get)</p><p></p><p>Ok, firstly make sure you have Visual Studio. Also, you need "Nuget Package Manager" for it.</p><p>If you don't have "Nuget Package Manager", Look up how to get it for visual studio.</p><p></p><p>Step 1 - Setting up the project</p><p>[spoiler]Firstly, make a new Visual C# Console application. And the install Discord.NET</p><p>To install Discord.NET, go to Tools and the hover over Nuget Package Manager.</p><p><img src="http://image.prntscr.com/image/5e3614ee5a8c4b238cfd68c5351f1352.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>Click "Manage NuGet Packages for Solution..."</p><p>After that, click Settings, in the bottom left (of the new tab). Make sure nuget.org is checked.</p><p><img src="http://image.prntscr.com/image/7b2ba9b908c94d89a774734822a695f5.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>When it's checked, press OK.</p><p>In the bar at the left, click "nuget.org". There should be a search bar in the top right. Search "Discord".</p><p>Click Discord.Net (Should be at the top).</p><p><img src="http://image.prntscr.com/image/b9ff66e754cd46dcba106500f1ff87e6.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>(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![/spoiler]</p><p></p><p>Step 2 - Setting up Bot</p><p>[spoiler]</p><p>Firstly, go here and create a new application. <a href="https://discordapp.com/developers/applications/me" target="_blank">Discord - Developer Documentation</a></p><p>Name it whatever you want. After that, go to the bottom and click create application.</p><p>Once that's done, You should see "Create bot user" Click it and you've setup the discord side of your bot!</p><p>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.</p><p>In your main function, make this:</p><p>[code]var bot = new Discord.DiscordClient();[/code]</p><p>This is used for controlling your Bot. It is a variable.</p><p>Now a few lines after that, add this:</p><p>[code]</p><p>bot.ExecuteAndWait(async () =></p><p> {</p><p> await bot.Connect("YOUR TOKEN HERE");</p><p> </p><p> });[/code]</p><p>Go to your bots discord page. It should be here <a href="https://discordapp.com/developers/applications/me" target="_blank">Discord - Developer Documentation</a></p><p>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.</p><p>Your main function should look a bit like this (without the red lines)</p><p><img src="http://image.prntscr.com/image/f60faa9b06f2467badbc0448577de618.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>Well done, your bot is all setup!</p><p>[/spoiler]</p><p></p><p>Step 3 - Commands</p><p>[spoiler]</p><p>Above this:</p><p>[code]</p><p>bot.ExecuteAndWait(async () =></p><p> {</p><p> await bot.Connect("YOUR TOKEN HERE");</p><p> </p><p> });[/code]</p><p>Add this:</p><p>[code]bot.MessageReceived += bot_MessageReceived;[/code]</p><p>Once you've done that, add this function:</p><p>[code]</p><p>static void bot_MessageReceived(object sender, Discord.MessageEventArgs e)</p><p> {</p><p></p><p></p><p> }[/code]</p><p>Make sure it is outside of your main function!</p><p>Now, it's time to add commands.</p><p>Here are some examples:</p><p>[code]</p><p>if(e.Message.RawText.StartsWith("Your Command"))</p><p> {</p><p> e.Channel.SendMessage(e.User.Mention + "Your reply");</p><p> }</p><p> else if(e.Message.RawText.StartsWith("Your 2nd Command"))</p><p> {</p><p> e.User.SendMessage("Direct Messaging");</p><p> }[/code]</p><p>Make sure they go in bot_MessageReceived.</p><p>and, if you type e and then a dot, you'll get a list of things you can do!</p><p>[/spoiler]</p><p></p><p>Step 4 - Adding the bot to a server.</p><p>[spoiler]</p><p>Adding a bot to a server is pretty simple.</p><p>Go to where your bot application thing is located and find Client Id, it should be at the top.</p><p>Example:</p><p><img src="http://image.prntscr.com/image/8a6ce9e75a9346d48bfbb0c111ce1ef7.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p><a href="https://discordapp.com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=0" target="_blank">https:// discordapp . com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=0</a></p><p>And then just do what is there and what it says. <img src="/styles/default/xenforo/smilies.emoji/people/smile.emoji.svg" class="smilie" loading="lazy" alt=":grinning:" title="Grinning :grinning:" data-shortname=":grinning:" /></p><p>[/spoiler]</p><p>If you have any questions or suggestions, please tell me in the comments!</p></blockquote><p></p>
[QUOTE="Craze, post: 10961, member: 3939"] [[ 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 [spoiler]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. [IMG]http://image.prntscr.com/image/5e3614ee5a8c4b238cfd68c5351f1352.png[/IMG] Click "Manage NuGet Packages for Solution..." After that, click Settings, in the bottom left (of the new tab). Make sure nuget.org is checked. [IMG]http://image.prntscr.com/image/7b2ba9b908c94d89a774734822a695f5.png[/IMG] 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). [IMG]http://image.prntscr.com/image/b9ff66e754cd46dcba106500f1ff87e6.png[/IMG] (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![/spoiler] Step 2 - Setting up Bot [spoiler] Firstly, go here and create a new application. [URL='https://discordapp.com/developers/applications/me']Discord - Developer Documentation[/URL] 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();[/code] This is used for controlling your Bot. It is a variable. Now a few lines after that, add this: [code] bot.ExecuteAndWait(async () => { await bot.Connect("YOUR TOKEN HERE"); });[/code] Go to your bots discord page. It should be here [URL='https://discordapp.com/developers/applications/me']Discord - Developer Documentation[/URL] 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) [IMG]http://image.prntscr.com/image/f60faa9b06f2467badbc0448577de618.png[/IMG] Well done, your bot is all setup! [/spoiler] Step 3 - Commands [spoiler] Above this: [code] bot.ExecuteAndWait(async () => { await bot.Connect("YOUR TOKEN HERE"); });[/code] Add this: [code]bot.MessageReceived += bot_MessageReceived;[/code] Once you've done that, add this function: [code] static void bot_MessageReceived(object sender, Discord.MessageEventArgs e) { }[/code] Make sure it is outside of your main function! 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"); }[/code] 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! [/spoiler] Step 4 - Adding the bot to a server. [spoiler] Adding a bot to a server is pretty simple. Go to where your bot application thing is located and find Client Id, it should be at the top. Example: [IMG]http://image.prntscr.com/image/8a6ce9e75a9346d48bfbb0c111ce1ef7.png[/IMG] [URL='https://discordapp.com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=0']https:// discordapp . com/oauth2/authorize?client_id=CLIENTID&scope=bot&permissions=0[/URL] And then just do what is there and what it says. :grinning: [/spoiler] If you have any questions or suggestions, please tell me in the comments! [/QUOTE]
Verification
Post reply
Forums
Tech Boards
Computer Programming
Source Code & Tutorial
[C#/Tutorial] How to make a Discord Bot (Outdated?)
CabConModding is now on facebook! Check the latest Updates, the Site Status and much more now!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top