Skip to content

Commit

Permalink
refactor(topic): update topics, add warning if invalid topic id
Browse files Browse the repository at this point in the history
We removed that the command itselfs locks the number to input. Now it just sends a warning if inputted the wrong number and gives out a random topic. This will also make room for a new feature o.O
  • Loading branch information
Pukimaa committed Jan 31, 2023
1 parent 2f4fa51 commit e14152d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 46 deletions.
12 changes: 6 additions & 6 deletions cogs/config/crosspost.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import i18n
import discord
from utils import get_language
from discord import app_commands
from discord.ext import commands

import i18n
from TakoBot import TakoBot
from utils import get_language


class Crosspost(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
def __init__(self, bot: TakoBot) -> None:
self.bot = bot

@app_commands.command(
Expand Down Expand Up @@ -64,6 +66,4 @@ async def on_message(self, message: discord.Message):
try:
return await message.publish()
except discord.HTTPException as e:
if e.code == 40033:
return
return print(e)
return
38 changes: 28 additions & 10 deletions cogs/misc/revive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .topics import questions
from discord import app_commands
from discord.ext import commands
from utils import get_language, translate, get_color
from utils import get_language, translate, get_color, error_embed


class Revive(commands.Cog):
Expand All @@ -18,20 +18,38 @@ def __init__(self, bot):
async def topic(
self,
interaction: discord.Interaction,
id: app_commands.Range[
int, 1, 144 # <-- Change the 2 to the amount of topics you have.
]
| None = None,
id: int | None = None,
):
locale = get_language(self.bot, interaction.guild.id)
id = randint(0, len(questions)) if not id else id
locale = get_language(self.bot, interaction.guild_id)
original_id = id
id = randint(0, len(questions)) if id == None else id
index = id - 1
embeds = []
files = []
valid_topic = True

if id > len(questions) or id <= 0:
id = randint(0, len(questions))
index = id - 1
valid_topic = False

embed = discord.Embed(
title=i18n.t("misc.topic_title", locale=locale),
description=await translate(questions[index], locale, "en"),
color=await get_color(self.bot, interaction.guild.id),
description= await translate(questions[index], locale, "en"),
color=await get_color(self.bot, interaction.guild_id), # type: ignore
)
embed.set_footer(text=i18n.t("misc.topic_footer", locale=locale, id=id))
embeds.append(embed)

if not valid_topic:
embed2, file = error_embed(
self.bot,
i18n.t("misc.topic_invalid_title", locale=locale, id=original_id),
i18n.t("misc.topic_invalid", locale=locale),
interaction.guild_id,
style="warning",
)
embeds = [embed2, embed]
files.append(file)

await interaction.response.send_message(embed=embed)
await interaction.response.send_message(embeds=embeds, files=files)
33 changes: 3 additions & 30 deletions cogs/misc/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
"What is the craziest dream you've ever had?",
"What is the most adventurous mode of transportation you've ever used?",
"What is the most adventurous thing you've ever eaten?",
"What is the most embarrassing app you have on your phone?",
"What is the most embarrassing piece of clothing you own?",
"What is the most embarrassing song on your playlist?",
"What is the most embarrassing thing in your room?",
"What is the most embarrassing thing that's happened to you while playing a sport?",
"What is the most embarrassing thing you've ever bought online?",
"What is the most embarrassing thing you've paid for with a payment app?",
"What is the most embarrassing thing you've posted on social media?",
"What is the most embarrassing thing you've searched for online?",
"What is the most embarrassing thing you've watched on streaming?",
"What is the most memorable book you've ever read?",
"What is the most memorable gift you've ever received?",
"What is the most memorable trip you've ever taken?",
Expand Down Expand Up @@ -82,7 +72,6 @@
"Have you ever actually kept a New Year's resolution?",
"Where's the most uncomfortable place you've ever slept?",
"Where do you waste the most time online?",
"What's the most embarrassing thing you've ever done in public?",
"What's the most useless piece of knowledge you know?",
"Have you traveled anywhere recently, or do you have any trips planned?",
"What's something interesting about you that most people don't know?",
Expand Down Expand Up @@ -124,23 +113,7 @@
"What is your favorite thing about your job or school and why?",
"What is your favorite thing about your friends and why?",
"If you could be any character from a book or movie, who would you be and why?",
"Write your response as professionally and educated as possible: What is your favorite hobby and why?",
"Write your response as if you were a toddler: If you could have any superpower, what would it be and why?",
"Write your response in the style of a Shakespearean play: If you could travel anywhere in the world, where would you go and why?",
"Write your response as if you were a pirate: What is your favorite thing about yourself and why?",
"Write your response in the style of a love letter: What is your favorite thing about your family and why?",
"Write your response as if you were a detective: If you could be any character from a book or movie, who would you be and why?",
"Write your response in the style of a rap song: If you could have any animal as a pet, which one would you choose and why?",
"Write your response as if you were a scientist: If you could only eat one type of food for the rest of your life, what would it be and why?",
"Write your response as if you were a superhero: What is your favorite memory from childhood and why?",
"Write your response in the style of a fairy tale: If you could learn any new skill, what would it be and why?",
"Write your response as if you were a baby: If you could be any age for a week, what age would you choose and why?",
"Write your response in the style of a news report: If you could switch lives with one person for a day, who would you choose and why?",
"Write your response as if you were a character from a video game: If you could travel back in time and visit any era, which one would you choose and why?",
"Write your response in the style of a cooking show: What is your favorite thing about your job or school and why?",
"Write your response as if you were a character from a TV show: What is your favorite thing about your friends and why?",
"Write your response in the style of a movie trailer: If you could be any character from a book or movie for a week, who would you be and why?",
"Write your response as if you were a politician: If you could have any superpower for a week, which one would you choose and why?",
"Write your response in the style of a fortune cookie: If you could be any age for a week, what age would you choose and why?",
"Write your response as if you were a character from a TV show: If you could switch lives with one person for a week, who would you choose and why?",
"What do you prefer? Apple or Android?",
"What do you prefer? PC or Console?",
"What do you prefer? AAA or Indie Games?",
]
2 changes: 2 additions & 0 deletions i18n/misc/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ en:
auto_translate_delete_original: "Deletion of the original message is now set to %{value}"
topic_title: "Here's your topic:"
topic_footer: "Topic ID: %{id}"
topic_invalid_title: "We couldn't find a Topic with the ID of `%{id}`"
topic_invalid: "We searched far and wide. Unfortunately, no topics were found.\nThat's why we picked a random topic for you. We hope you like it."
auto_react_added: "%{emoji} will now be added to every message in %{channel}"
auto_react_removed: "%{emoji} will no longer be added to every message in %{channel}"
auto_react_empty: "No emojis are set to be added to every message in %{channel}"
Expand Down

0 comments on commit e14152d

Please sign in to comment.