2023-02-22 17:41:33 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import discord
|
|
|
|
import json
|
|
|
|
import random
|
|
|
|
|
|
|
|
intents = discord.Intents.default()
|
|
|
|
intents.message_content = True
|
|
|
|
|
|
|
|
client = discord.Client(intents=intents)
|
|
|
|
|
|
|
|
gifs = {}
|
|
|
|
with open("gifs.json") as file:
|
|
|
|
gifs = json.load(file)
|
|
|
|
|
|
|
|
# Commands
|
2023-02-22 17:46:54 +00:00
|
|
|
# Gif commands
|
2023-02-22 17:41:33 +00:00
|
|
|
|
|
|
|
|
2023-02-22 17:46:54 +00:00
|
|
|
async def gif_handler(message: discord.Message, command: list[str]):
|
|
|
|
gif_kind = command[0]
|
|
|
|
|
2023-02-22 17:41:33 +00:00
|
|
|
target = ""
|
|
|
|
if len(command) <= 1:
|
|
|
|
target = f"<@{message.author.id}>"
|
|
|
|
else:
|
|
|
|
target = command[1]
|
|
|
|
|
2023-02-22 17:46:54 +00:00
|
|
|
if gif_kind not in gifs:
|
2023-02-22 17:41:33 +00:00
|
|
|
await message.reply(
|
2023-02-22 17:46:54 +00:00
|
|
|
"im so sorry, i have no such thing to give you for now... come back later :3")
|
2023-02-22 17:41:33 +00:00
|
|
|
|
2023-02-22 17:46:54 +00:00
|
|
|
choosen_gif = random.choice(gifs[gif_kind])
|
|
|
|
await message.reply(f"here u go {target}\n{choosen_gif}")
|
2023-02-22 17:41:33 +00:00
|
|
|
|
2023-02-22 17:46:54 +00:00
|
|
|
GIF_COMMANDS = [
|
|
|
|
"hug",
|
|
|
|
"kiss",
|
|
|
|
"cuddle",
|
|
|
|
"hold",
|
|
|
|
]
|
2023-02-22 17:41:33 +00:00
|
|
|
|
|
|
|
# Discord events
|
|
|
|
|
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_message(message: discord.Message):
|
|
|
|
if message.author.bot == True:
|
|
|
|
return
|
|
|
|
|
|
|
|
# TODO: Do proper parsing of the message
|
|
|
|
message_as_command = message.content.split(" ")
|
|
|
|
|
|
|
|
command = message_as_command[0]
|
2023-02-22 17:46:54 +00:00
|
|
|
if command in GIF_COMMANDS:
|
|
|
|
await gif_handler(message, message_as_command)
|
2023-02-22 17:41:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
client.run(open("token").read())
|