Skip to content

Commit 51fec15

Browse files
authored
Merge pull request larymak#311 from LiamBrinkmann/main
Added the discord bot template
2 parents 77d0cc5 + b9154f8 commit 51fec15

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

BOTS/DiscordBotTemplate/Main.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import discord
2+
import os
3+
from random import randint
4+
5+
TOKEN = "" #place your bots token here
6+
7+
bot = discord.Bot() #defines the bot
8+
9+
#this event will print to the console when the bot is running and ready for commands
10+
@bot.event
11+
async def on_ready():
12+
print(f'{bot.user} is ready')
13+
14+
#below are the commands, have fun with it, you are only limited by your imagination
15+
16+
#Example command, test it in your server using /hello
17+
@bot.slash_command(name = "hello", description = "Say hello to the bot")
18+
async def hello(ctx):
19+
await ctx.respond("Hey!")
20+
21+
#another example, here the bot will provide a random number between 1 and 10.
22+
@bot.slash_command(name = "random", description = "get a random number between 1 and 10")
23+
async def random(ctx):
24+
await ctx.respond(randint(1,10))
25+
26+
27+
bot.run(TOKEN) #this line is what runs the bot itself

BOTS/DiscordBotTemplate/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### A Discord Bot template
2+
3+
#### Requirements:
4+
- Python3
5+
- pip
6+
- Pycord
7+
8+
### Not required but useful
9+
- dotenv
10+
11+
#### Getting started
12+
You will need to create a bot using the discord developer portal
13+
you will also need to pip install both pycord
14+
15+
I would recommend getting dotenv and saing your token in that file, however it is not necessary if you plan to keep
16+
the bot running on your local machine only and do not plan to upload it to github.
17+
18+
once you have created your bot you can under OAuth2 you can select the permissions your bot needs and get the link to invite the bot to a server.
19+
once done go to the Bot tab and copy your Token. You will place this in a .env file.
20+
eg: Token = ygawiushjfgblfkhkjbn
21+
this is to keep the token safe if you plan on uploading it to your own github repository. Otherwise you can place it directly inside the main.py file.
22+
23+
Now you can create any further commands you would like and enjoy your very own customisable discord bot.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
py-cord==2.4.1

0 commit comments

Comments
 (0)