Skip to content

edagener0/New-News

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

New News

Table of contents

  1. What is New News?
  2. Why New News?
  3. APIs
  4. Functionalities
    1. Cats Cog
      1. Cat Fact
      2. Sifet's Cats
      3. Cat Embed
      4. Daily Cat
    2. Jokes Cog
      1. Joke
      2. Blacklist Joke Category
      3. Allow Joke Category
      4. Show Blacklisted Joke Categories
    3. Kanye Cog
      1. Kanye Quote
    4. Memes Cog
      1. Memes
    5. Music Cog
      1. Play
      2. Resume
      3. Pause
      4. Skip
      5. Disconnect
      6. Queue
    6. News Cog
      1. Send News
    7. Trivia Cog
      1. Trivia
    8. Urban Dictionary Cog
      1. Urban Dictionary term definition
    9. Youtube Cog
      1. Download Music
    10. Relevant information

What is New News?

  • New News is a simple Discord Bot with many different functionalities like playing music, downloading music from youtube, sending cats, memes and lots of more exciting stuff.
  • The bot was created using the programming language Python and Nextcord, a modern API wrapper for Discord, forked from discord.py.
  • The bot uses cogs to organize commands, listeners and state into a single class. The cogs are then loaded into the bot, extending it's functionality.

Why New News?

  • Initially the bot was supposed to be far simpler. It's purpose was to just send news at a specific time of the day using the NewsAPI.
  • As I started enjoying the development process more and more I kept adding new functionalities to it.
  • Eventually the project grew a lot more and interacted with far more APIs, making the name New News weird because the bot doesn't only send news.
  • Though it's a weird name I like it and decided to keep it to the end as it represents the humble beginnings of the project.

APIs

Functionalities

  • The bot's functionalities are embeded into it's cogs.
  • I'll go over each cog and explain the functionality of the commands in it.

Cats Cog

  • This cog provides functionalities related to cats like sending cat facts and images.

Cat Fact

  • When you type in this command the bot will answer you with a random cat fact.
/cat_fact

Sifet's Cats

  • This command will fetch a random cat picture from my friends API and answer your command with it.
/sifets_cats

Cat Embed

  • This command will fetch a random cat picture from my friend's API and get a random cat fact from the Cat Facts API.
  • After fetching all the necessary data it will create an embed and answer you.

Daily Cat

  • This is not a command, it's a functionality of the cog as a whole.
  • The bot creates a task for each guild that it is in and proceeds to send a cat embed to every single member on it at a specific time of the day.

Jokes Cog

  • This Cog holds the functionality for several commands related to jokes like sending random jokes, blacklist or allowing certain joke categories and more.

Joke

  • This command will send a joke as an answer to your command.
/joke

Blacklist Joke Category

  • With this command you are able to select joke categories to blacklist.
/blacklist_joke_category <category>

Allow Joke Category

  • With this command you are able to select joke categories to allow.
/allow_joke_category <category>

Show Blacklisted Joke Categories

  • With this command you're able to get all currently blacklisted categories.
/show_blacklisted_joke_categories

Kanye Cog

  • This cog is fairly simple and only has 1 command.

Kanye Quote

  • This command gets a random quote from Kanye's rest API and then proceeds to create an embed with the quote and a previously defined image of Kanye. The embed is then sent as an answer.
/kanye_quote

Memes Cog

  • This cog is fairly simple and only has 1 command.

Memes

  • This command sends a request to the Memes API, extracts the list of urls for the memes and then proceeds to send them all, one by one, as an answer.
  • It takes an argument count which should be a value between 1 and 50. In case the user enters a value below one it defaults to 1. If the value is over 50 it defaults to 50.
/memes <count>

Music Cog

  • This cog is complex and is responsible for holding all the commands for playing, pausing and resuming music. A queue functionality was also added.
  • Keep in mind that this bot uses a Lavalink Server to play the audios of the videos / musics from Youtube.

Play

  • This command plays a song if there is no song playing or the bot isn't in the channel. If the bot is already playing a song then it will add the song to the queue.
  • You will have to provide a search term for the bot to look for the desired music / video. The bot will always return the first match to your search term.
/play <search>

Resume

  • If the current playing song is paused it resumes the song.
/resume

Pause

  • If the current song is playing it pauses the song.
/pause

Skip

  • Skips the song that is currently playing.
/skip

Disconnect

  • Disconnects the bot from the voice channel he is in.
/disconnect

Queue

  • Shows the bot's song queue.
/queue

News Cog

  • This cog holds the functionality for all news related functions.
  • This cog doesn't have any commands but holds the core of the project as even the name of the bot was based on this functionality.

Send News

  • This is not a command but rather a functionality of the cog as a whole.
  • A task will be created and executed at a specific time for each guild that the bot is in.
  • Basically it will create a new category called News and create a channel inside that category for each different type of news.

Trivia Cog

  • This cog is responsible for generating trivia questions for the guild.

Trivia

  • Each trivia question has a duration of 10 seconds, after which the results of the poll / trivia question will be published as an embed.
  • This command has two optional parameters, and .
  • If specified the question's category and difficulty will reflect the options chosen.
/trivia <category> <difficulty>

Urban Dictionary Cog

  • This cog is responsible for searching the UrbanDictionary for a specific term.

Urban Dictionary term definition

  • This command will search the urban dictionary for a specific term and return the first couple results.
  • All fetched data will be processed and turned into embeds.
  • All the embeds created will be sent as an answer to the command.
/urban_dict <search>

Youtube Cog

  • This cog is responsible for downloading audio and metadata for a specified video / music in youtube.
  • This cog needs FFmpeg installed to work properly.

Download Music

  • This command downloads the audio and metadata for a specified url for a Youtube video.
  • All the donwloaded content gets put together using FFmpeg, generating an mp3 file.
  • The file is then sent as an answer to the command.
/download <url>

Relevant information

  • No API keys were left in the code. All API keys are in a .env file and are loaded into the code at run time.
  • The Bot's class is located in the bot_main.py file. The class is used to generate an object for our bot whose functionalities are then extended by adding cogs to it.
  • The main.py file is responsible for running the bot as a whole. Functions responsible for creating the bot, loading the cogs and running it are all there.
  • The views.py file holds two classes that use nextcord.ui to create a Dropdown Menu to hold all possible choices for the trivia game. The contents of this file are used inside the Trivia Cog.
  • If you ever want to self-host the bot but don't want certain cogs / features to load you can just put the cog's name (e.g. trivia.py) inside the BLACKLISTED list in the main.py file. It will prevent all the functionalities related to that cog from loading.

Self-Hosting

  1. Download the project.
    git clone https://github.com/edagener0/New-News.git
    cd New-News
    
  2. Self-host a lavalink server.
  3. Run the lavalink server.
  4. Insert the credentials to access your lavalink server in the environmental file.
  5. Run the bot.
    python main.py
    

Note: Don't forget to put your tokens for the necessary APIs and lavalink server in the .env file.

About

A Discord Bot with different functionalities and API interactions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages