mirror of
https://gitlab.jonasled.de/jonasled/discordbot
synced 2024-07-11 19:58:33 +02:00
added cat command
This commit is contained in:
parent
8c6a221915
commit
af927eced1
21
bot.py
21
bot.py
|
@ -9,12 +9,12 @@ from config import *
|
||||||
from requests import get
|
from requests import get
|
||||||
from json import loads
|
from json import loads
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
from os import listdir
|
from os import rename, remove, listdir
|
||||||
from os import rename, remove
|
|
||||||
from youtube_dl import YoutubeDL
|
from youtube_dl import YoutubeDL
|
||||||
from time import time
|
from time import time
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
polls = {}
|
polls = {}
|
||||||
player = None #the Player for the music Bot
|
player = None #the Player for the music Bot
|
||||||
|
@ -393,6 +393,23 @@ async def result(ctx, id):#this function prints the result of a poll
|
||||||
dbcursor.execute("DELETE FROM poll where pollID = ?", [id])#delete the entries from the poll in the database
|
dbcursor.execute("DELETE FROM poll where pollID = ?", [id])#delete the entries from the poll in the database
|
||||||
dbconnection.commit()#write the database to disk
|
dbconnection.commit()#write the database to disk
|
||||||
|
|
||||||
|
# _____ _
|
||||||
|
# / ____| | |
|
||||||
|
# | | __ _ | |_
|
||||||
|
# | | / _` || __|
|
||||||
|
# | |____| (_| || |_
|
||||||
|
# \_____|\__,_| \__|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
@bot.command(pass_context=True, brief="sends a random cat picture")
|
||||||
|
async def cat(ctx):
|
||||||
|
r = get("http://aws.random.cat/meow")
|
||||||
|
answer = loads(r.text)
|
||||||
|
r = get(answer["file"])
|
||||||
|
image_data = BytesIO(r.content)
|
||||||
|
image_data.seek(0)
|
||||||
|
await ctx.send(file=discord.File(image_data, 'cat.jpg'))
|
||||||
# ___ ___ _ ______ _
|
# ___ ___ _ ______ _
|
||||||
# | \/ | (_) | ___ \ | |
|
# | \/ | (_) | ___ \ | |
|
||||||
# | . . | _ _ ___ _ ___ | |_/ / ___ | |_
|
# | . . | _ _ ___ _ ___ | |_/ / ___ | |_
|
||||||
|
|
Loading…
Reference in a new issue