aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar glowingrunes <[email protected]>2019-04-28 16:32:42 +0100
committerGravatar glowingrunes <[email protected]>2019-04-28 16:32:42 +0100
commite76c79d68829d3ff7401e0b02acdd80f9616abfd (patch)
tree438490ffabe2f80ffed6bd30bde7387f1e75e23a
parentCreated a JSON file to store the bunny names. (diff)
Finished the random bunny name generator command.
-rw-r--r--bot/seasons/easter/bunny_name_generator.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/bot/seasons/easter/bunny_name_generator.py b/bot/seasons/easter/bunny_name_generator.py
new file mode 100644
index 00000000..b2bfb893
--- /dev/null
+++ b/bot/seasons/easter/bunny_name_generator.py
@@ -0,0 +1,25 @@
+import random
+import json
+import logging
+
+from discord.ext import commands
+from pathlib import Path
+
+
+log = logging.getLogger(__name__)
+
+with open(Path("bot", "resources", "easter", "bunny_names.json"), "r", encoding="utf8") as f:
+ BUNNY_NAMES = json.load(f)
+
+
+class BunnyNameGenerator(commands.Cog):
+ """Generate a random bunny name, or bunnify your Discord username!"""
+
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.command()
+ async def bunnyname(self, ctx):
+ """Picks a random bunny name from a JSON file"""
+
+ await ctx.send(random.choice(BUNNY_NAMES["names"]))