- What is New News?
- Why New News?
- APIs
- Functionalities
- 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.
- 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.
- The bot used many APIs to provide results to user's commands.
- 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.
- This cog provides functionalities related to cats like sending cat facts and images.
- When you type in this command the bot will answer you with a random cat fact.
/cat_fact
- This command will fetch a random cat picture from my friends API and answer your command with it.
/sifets_cats
- 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.
- 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.
- This Cog holds the functionality for several commands related to jokes like sending random jokes, blacklist or allowing certain joke categories and more.
- This command will send a joke as an answer to your command.
/joke
- With this command you are able to select joke categories to blacklist.
/blacklist_joke_category <category>
- With this command you are able to select joke categories to allow.
/allow_joke_category <category>
- With this command you're able to get all currently blacklisted categories.
/show_blacklisted_joke_categories
- This cog is fairly simple and only has 1 command.
- 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
- This cog is fairly simple and only has 1 command.
- 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>
- 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.
- 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>
- If the current playing song is paused it resumes the song.
/resume
- If the current song is playing it pauses the song.
/pause
- Skips the song that is currently playing.
/skip
- Disconnects the bot from the voice channel he is in.
/disconnect
- Shows the bot's song queue.
/queue
- 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.
- 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.
- This cog is responsible for generating trivia questions for the guild.
- 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>
- This cog is responsible for searching the UrbanDictionary for a specific term.
- 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>
- This cog is responsible for downloading audio and metadata for a specified video / music in youtube.
- This cog needs FFmpeg installed to work properly.
- 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>
- 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.
- Download the project.
git clone https://github.com/edagener0/New-News.git cd New-News - Self-host a lavalink server.
- Run the lavalink server.
- Insert the credentials to access your lavalink server in the environmental file.
- 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.