First post. How exciting!

My first post ever on this website!

First post. How exciting!
Photo by Imagine Buddy / Unsplash

Here we are. My first post ever on this website. Hopefully I'll have motiviation to keep this site updated. I don't expect it to be a full blown masterpiece but we gotta start with something at least right? I'm also writing this at my workplace. I got some good news from my boss and that's why I'm excited to write this post too.


My python journey

In my free time I have been ironing out my Python skills. I completed my first python chapter on Codedex. Such a cool website. Look at this pixel art! So pretty.

Learned about classes, objects, functions etc. I will soon move on to an advanced course and continue there. I got a free 6 month access because I'm a student. If you are one too - it's really worth giving it a try. Please do not ask me to help you with your Python homework tho.

With my newfound knowledge I decided to make a tiny project. A discord bot. It's nothing special really. It basically posts memes on the discord channel that you use the command in. It takes them from Reddit which is nice since there's a low chance of having a duplicate posts. It uses discord's API to gather information about who is posting a command and where, then it goes to reddit, makes a JSON file which then turns into a picture or a gif and posts it in the channel. Here is a code for it if you're curious:

import discord
import requests
import json

def get_meme():
    response = requests.get('https://meme-api.com/gimme')
    json_data = json.loads(response.text)
    return json_data['url']

class MyClient(discord.Client):
  
  async def on_ready(self):
    print('Logged on as {0}!'.format(self.user))
  
  async def on_message(self, message):
    if message.author == self.user:
        return
    if message.content.startswith('$meme'):
        await message.channel.send(get_meme())

  
intents = discord.Intents.default()
intents.message_content = True

client = MyClient(intents=intents)
client.run('xxx') # Replace with your own token.

Pretty cool right? It's so basic it's kinda sad honestly and I know that but listen. This is something, a step into a right direction. Gotta start with something tiny then move on to bigger projects.