Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Space Enthusiast Discord Bot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Discord Space Bot

A shooting star⭐, let this Space Enthusiastic Space Discord Bot to quickly streak across the skies off your Discord Server

## Link
You can join the server to try the Bot<br>
[Discord Space Bot](https://discord.gg/kMHhQW5dRR)

## Installation
**STEP 1:** Create a virtual environment and clone the repository inside it.

**STEP 2:** Use the package manager [pip](https://pip.pypa.io/en/stable/) to install all the dependencies mentioned in requirements.txt.
```bash
pip install -r .\requirements.txt
```

## Usage
**STEP 1:** Make a Discord Server and open the [Discord's Developers Portal](https://discord.com/developers/docs/intro) and navigate to [Applications](https://discord.com/developers/applications)

![Application Portal](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/application-portal.png)

**STEP 2:** Click on [New Application]() and create a new application
![New Application](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/create-app.png)

**STEP 3:** Add a Bot to your Application
![Add Bot](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/add-bot.png)

**STEP 4:** Copy the Bot Token and Paste it in the [discordbot.py](discordbot.py) file in the "token" variable.
![Copy Token](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/token.png)

**STEP 5:** Go to OAuth2 and in **SCOPES** select _BOT_
![Scope-Bot](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/scope-bot.png)

**STEP 6:** Then set **BOT PERMISSIONS**
![Bot-Permission](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/bot-permissions.png)
_NOTE:You can choose "Administrator" but it's not advisable_

**STEP 7:** Copy the URL given after Scopes
![Copy-URL](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/copy-oAuth-url.png)

**STEP 8:** The URL will redirect you to the following page. Select your Server Name.
![Server-Select](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/select-server.png)

**STEP 9:** After successful Authorization this page will occur. Close the tab and open your Discord Server. The bot will have joined it.
![Authorized](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/authorized.png)

**STEP 10:** On you local machine, run the [discordbot.py](discordbot.py) file in the commandline as follows
```bash
python discordbot.py
```
_NOTE: You can also run it using Spyder IDE_

_**YOUR BOT WILL BE UP AND RUNNING**_

## Sample Screenshots of Bot in Action
![Bot-Test1](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/bot-test-1.png)
![Bot-Test2](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/bot-test-2.png)
![Bot-Test3](https://github.com/SrishtiSinghD/100LinesOfCode/blob/DiscordBot/Space%20Enthusiast%20Discord%20Bot/pictures/bot-test-3.png)

## Author<br>
_**Srishti Singh**_<br>
Github: [SrishtiSinghD](https://github.com/SrishtiSinghD)
97 changes: 97 additions & 0 deletions Space Enthusiast Discord Bot/discordbot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#Importing Modules Needed
import discord as ds
from discord.ext import commands
import random, sys
import requests
import json
import nest_asyncio
nest_asyncio.apply() #needed to keep the python script running in Spyder IDE!

#Nebula Tuple
nebulaList = ("Orion Nebula.jpg","Eagle Nebula.jpg","Crab Nebula.jpg",\
"Ring Nebula.jpg","Helix Nebula.jpg","Horsehead Nebula.jpg",\
"Carina Nebula.jpg","Lagoon Nebula.jpg","Cat's Eye Nebula.jpg",\
"Butterfly Nebula.jpg","Veil Nebula.jpg","Hourglass Nebula.jpg")
#Planet Factopedia Tuple
planetList = ("Mercury is hot, but not too hot for ice",\
"Venus doesn’t have any moons, and we aren’t sure why.",\
"The Earth’s Molten Iron Core Creates a Magnetic Field",\
"Mars had a thicker atmosphere in the past.",\
"Jupiter is a great comet catcher.",\
"No one knows how old Saturn’s rings are",\
"Uranus is more stormy than we thought.",\
"Neptune has supersonic winds.")
#Tuple of emojis (Can add more)
emojiList = ('💖','❤','😒','😎','😜','👌','🌹','😁','🤳',\
'🎃','😍','🤩','😪','🥳')

"""LIST OF HELPER FUNCTIONS"""
#Helper function to get quotes from zenquotes
def get_quotes():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
print(json_data)
quote = json_data[0]['q']+" -"+json_data[0]['a']
return quote

#Token of Bot - Copy from Developer Discord Portal
token = <bot_token>

#2. Making Bot Object with prefix as $(prefix symbol can be changed)
client = commands.Bot(command_prefix="$")

"""LIST OF COMMANDS"""

#$hello - Says hello to the user
@client.command(name = "hello")
async def hello(ctx):
await ctx.message.channel.send("Hello!!! {0.author.display_name}".format(ctx.message))
await ctx.message.add_reaction('👋')
#$inspire - Returns a quote scraped from zenquotes.io
@client.command(name = "inspire")
async def inspire(ctx):
await ctx.message.channel.send(get_quotes())
#$emotion - Returns a random emoji from emoji tuple
@client.command(name = "emotion")
async def giveEmoji(ctx):
await ctx.message.channel.send(random.choice(emojiList))
#$planet <n> - Gives a fact and picture of the nth planet
@client.command(name = "planet")
async def planet(ctx,arg1):
num = int(arg1)-1
if num in range(0,8):
s = planetList[num]
fs = "planets/"+arg1+".jpg"
await ctx.send(s)
await ctx.send(file = ds.File(fs))
else:
await ctx.send("Invalid Planet Number Given! Try giving number between 1-8 🤔")
#$nebula - Gives the name and picture of a nebula randomly
@client.command(name = "nebula")
async def nebula(ctx):
fs = "nebulas/"+random.choice(nebulaList)
s = fs[8:-4]
await ctx.send(s)
await ctx.send(file = ds.File(fs))

#When Bot comes Online, prints the message below on console
@client.event
async def on_ready():
print("We are logged in as {0.user}".format(client))


#Event carried out when a user send a message
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content.lower()
#Says hello back when greeted with "Hello Botname" message
if msg.startswith('hello') and "bot-name" in msg:
await message.channel.send("Hello👋 {}".format(message.author.display_name))
await message.add_reaction('👋')
await client.process_commands(message)

#Starts running the Bot
client.run(token)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Space Enthusiast Discord Bot/nebulas/paulina.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Space Enthusiast Discord Bot/pictures/token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Space Enthusiast Discord Bot/planets/1.jpg
Binary file added Space Enthusiast Discord Bot/planets/2.jpg
Binary file added Space Enthusiast Discord Bot/planets/3.jpg
Binary file added Space Enthusiast Discord Bot/planets/4.jpg
Binary file added Space Enthusiast Discord Bot/planets/5.jpg
Binary file added Space Enthusiast Discord Bot/planets/6.jpg
Binary file added Space Enthusiast Discord Bot/planets/7.jpg
Binary file added Space Enthusiast Discord Bot/planets/8.jpg
21 changes: 21 additions & 0 deletions Space Enthusiast Discord Bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
aiohttp==3.7.4.post0
appdirs==1.4.4
async-timeout==3.0.1
attrs==21.2.0
certifi==2021.5.30
chardet==4.0.0
charset-normalizer==2.0.4
discord==1.7.3
discord.py==1.7.3
distlib==0.3.2
filelock==3.0.12
idna==3.2
multidict==5.1.0
nest-asyncio==1.5.1
pytube==11.0.1
requests==2.26.0
six==1.16.0
typing-extensions==3.10.0.1
urllib3==1.26.6
virtualenv==20.4.7
yarl==1.6.3