diff --git a/README.md b/README.md index 0ff2ded..8d4aff5 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,12 @@ away - Originally by Paddo, written for v3 by Axas, final tests by aikaterna. Se blurplefy - Make an avatar or an image upload blurple for Discord's 3rd anniversary. +cah - Cards Against Humanity, played in DM's. This can rate limit large bots via the sheer number of messages sent. Install and use with caution on larger bots. + chatchart - Generates a pie chart to display chat activity over the last 5000 messages. Requested by violetnyte. +dictonary - I stole this from UltimatePancake's v2 cogs, defines words via a dictonary. Only the "define" command for now until the dependency owner updates their files with a pending PR. + dungeon - New users with new accounts will be shuffled off to a locked channel on-join to help mitigate raiders. Please see the dungeon_readme.md file on this repo for more information. imgwelcome - The repo can be found at: https://github.com/aikaterna/imgwelcome diff --git a/dictionary/__init__.py b/dictionary/__init__.py new file mode 100644 index 0000000..e943b1d --- /dev/null +++ b/dictionary/__init__.py @@ -0,0 +1,5 @@ +from .dictionary import Dictionary + + +def setup(bot): + bot.add_cog(Dictionary(bot)) diff --git a/dictionary/dictionary.py b/dictionary/dictionary.py new file mode 100644 index 0000000..38dde5e --- /dev/null +++ b/dictionary/dictionary.py @@ -0,0 +1,38 @@ +from redbot.core import commands +from PyDictionary import PyDictionary + + +class Dictionary(commands.Cog): + """Word, yo""" + + def __init__(self, bot): + self.bot = bot + self.dictionary = PyDictionary() + + @commands.command() + async def define(self, ctx, *, word: str): + """Displays definitions of a given word.""" + search_msg = await ctx.send("Searching...") + search_term = word.split(" ", 1)[0] + result = self.dictionary.meaning(search_term) + str_buffer = "" + if result is None: + await search_msg.edit(content="This word is not in the dictionary.") + return + for key in result: + str_buffer += "\n**" + key + "**: \n" + counter = 1 + j = False + for val in result[key]: + if val.startswith("("): + str_buffer += str(counter) + ". *" + val + ")* " + counter += 1 + j = True + else: + if j: + str_buffer += val + "\n" + j = False + else: + str_buffer += str(counter) + ". " + val + "\n" + counter += 1 + await search_msg.edit(content=str_buffer) diff --git a/dictionary/info.json b/dictionary/info.json new file mode 100644 index 0000000..a20fc04 --- /dev/null +++ b/dictionary/info.json @@ -0,0 +1,16 @@ +{ + "author": [ + "UltimatePancake" + ], + "description": "Gets definitions for given words", + "install_msg": "`[p]define ` to define a word after loading the cog with `[p]load dictionary`.", + + "requirements": [ + "PyDictionary" + ], + "short": "Gets definitions for given words", + "tags": [ + "dictionary" + ], + "type": "COG" +}