-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import json | ||
|
||
import discord | ||
from discord.ext import commands | ||
from discord import app_commands | ||
|
||
|
||
class Ship(commands.Cog, name="ship"): | ||
def __init__(self): | ||
super().__init__() | ||
self.thresholds = {} | ||
|
||
async def cog_load(self): | ||
await super().cog_load() | ||
print("Ship Cog Loaded") | ||
|
||
async def load_data(self): | ||
with open("data/ship-thresholds.json", "r", encoding="utf-8") as f: | ||
self.thresholds = json.load(f) | ||
|
||
def get_slogan(self, compat) -> tuple[str, str]: | ||
for threshold, data in self.thresholds.items(): | ||
if compat >= int(threshold): | ||
return data["message"], data["image"] | ||
return ("", "") | ||
|
||
@app_commands.command( | ||
name="ship", description="Calculates the compatibility between two people" | ||
) | ||
async def ship( | ||
self, | ||
intr: discord.Interaction, | ||
first_user: discord.User, | ||
second_user: discord.User, | ||
): | ||
if first_user.id == second_user.id: | ||
await intr.response.send_message("No narcissism allowed.", ephemeral=True) | ||
return | ||
|
||
compat = (first_user.id + second_user.id) % 101 | ||
slogan, image = self.get_slogan(compat) | ||
|
||
embed = discord.Embed( | ||
type="rich", | ||
title=f"{first_user.display_name} and {second_user.display_name} are {compat}% compatible!", | ||
description=slogan, | ||
) | ||
embed.set_thumbnail(url=image) | ||
|
||
await intr.response.send_message(embed=embed) | ||
|
||
|
||
async def setup_ship(bot, guilds): | ||
cog = Ship() | ||
await cog.load_data() | ||
await bot.add_cog(cog, guilds=guilds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"95": { | ||
"message": "TRUE LOVE!!!", | ||
"image": "https://cdn.discordapp.com/emojis/1090118781818388481.webp" | ||
}, | ||
"75": { | ||
"message": "Lovely!", | ||
"image": "https://cdn.discordapp.com/emojis/1132861877647589376.webp" | ||
}, | ||
"50": { | ||
"message": "Okay!", | ||
"image": "https://cdn.discordapp.com/emojis/1066954556753330236.webp" | ||
}, | ||
"25": { | ||
"message": "Many fish in the sea...", | ||
"image": "https://cdn.discordapp.com/emojis/1086538148252745768.gif" | ||
}, | ||
"10": { | ||
"message": "Yikes...", | ||
"image": "https://cdn.discordapp.com/emojis/1097261807548256256.webp" | ||
}, | ||
"0": { | ||
"message": "...", | ||
"image": "https://cdn.discordapp.com/emojis/1039832025194041354.webp" | ||
} | ||
} |