Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xtaufeeq/Astronomy-Discord-Bot
Astronomy-Discord-Bot is an open-source Discord Bot that automatically sends "Astronomy Picture Of The Day" and posts it in a channel on your server. Each day a different image or photograph of our universe is featured, along with a brief explanation written by a professional astronomer. Astronomy Picture of the Day is provided by NASA and Michigan Technological University.
https://github.com/0xtaufeeq/Astronomy-Discord-Bot
astronomy astrophysics discord discord-bot discord-py discordpy hacktoberfest hacktoberfest2022 nasa-api nasa-apod python
Last synced: 3 months ago
JSON representation
Astronomy-Discord-Bot is an open-source Discord Bot that automatically sends "Astronomy Picture Of The Day" and posts it in a channel on your server. Each day a different image or photograph of our universe is featured, along with a brief explanation written by a professional astronomer. Astronomy Picture of the Day is provided by NASA and Michigan Technological University.
- Host: GitHub
- URL: https://github.com/0xtaufeeq/Astronomy-Discord-Bot
- Owner: 0xtaufeeq
- Created: 2021-07-26T06:54:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-29T20:02:10.000Z (over 3 years ago)
- Last Synced: 2024-07-15T10:45:39.583Z (6 months ago)
- Topics: astronomy, astrophysics, discord, discord-bot, discord-py, discordpy, hacktoberfest, hacktoberfest2022, nasa-api, nasa-apod, python
- Language: Python
- Homepage: https://taufeeq.team
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Astronomy-Discord-Bot
# Code
```py
from os import name
import discord
import aiohttp
import requests
from discord_components import*
from discord import flags
from discord.ext import commands, tasksclient = commands.Bot(command_prefix=commands.when_mentioned_or('.'))
client.remove_command('help')aopdkey = "AOPDKEY"
@client.command()
async def apod(ctx):
client.ses = aiohttp.ClientSession()
url = f'https://api.nasa.gov/planetary/apod?api_key={aopdkey}'
async with client.ses.get(url) as r:
if r.status in range(200, 299):
data = await r.json()
url = data['url']
imgtitle = data['title']
imgdate = data['date']
explanation = data['explanation']
ogimg = data['hdurl']
credit = data['copyright']
embed = discord.Embed(
title='🌠Astronomy Picture Of The Day',
description=f'**Date -** {imgdate}', color = 000000, timestamp=ctx.message.created_at).set_image(
url=url).add_field(name=imgtitle,
value=f'**Explaination - **\n{explanation}').add_field(name='Original Image -',
value=f'[Click Here]({ogimg})',inline=False).add_field(name='Image Credit & Copyright -',
value=credit).set_footer(text="Requested by: {}".format(ctx.author.display_name))
await ctx.send(embed=embed,
components=[
Button(style=ButtonStyle.URL, label='View in browser', url='https://apod.nasa.gov/apod/astropix.html')
],
)
@client.event
async def on_ready():
DiscordComponents(client)
print(f'{client.user} has connected to Discord!')client.run('BOT-TOKEN')```