diff --git a/README.md b/README.md new file mode 100644 index 0000000..42dd16d --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# [ROO] Berry Reminder Bot + +This is a simple Discord bot to help users set reminders for harvesting Leppa Berries and Gracidea Flowers, as well as watering their berries. + +The bot can be found at {TODO Add Link to Bot} + +## Usage + +### Commands + +- `!leppa`: Sets a reminder to harvest Leppa Berries in 20 hours. +- `!gracidea`: Sets a reminder to harvest Gracidea Flowers in 44 hours. +- `!water `: Sets a custom reminder to water berries in the specified duration (in hours). +- `!reminders`: Lists all active reminders for the user. +- `!cancel`: Cancels all active reminders for the user. + +### Example + +User: `!leppa` +Bot: `Reminding @User to harvest Leppa Berry in 20 hours` + +User: `!gracidea` +Bot: `Reminding @User to harvest Gracidea Flower in 44 hours` + +User: `!water 3` +Bot: `Reminding @User to water their berries in 3 hours` + +User: `!reminders` +Bot: `@User, you have the following active reminders: +leppa +gracidea +water` + +User: `!cancel` +Bot: `@User, all of your reminders have been cancelled.` + + +## Project Setup + +1. Install the required dependencies using pip: `pip install discord.py` +2. Replace `YOUR_TOKEN_HERE` in the last line of the code with your bot's token (or better yet, use an environment variable) + +### Running the Bot Locally + +To run the bot, simply execute the Python script: `python berry_reminder_bot.py` + + + + diff --git a/README.txt b/README.txt deleted file mode 100644 index 85246a8..0000000 --- a/README.txt +++ /dev/null @@ -1,34 +0,0 @@ -ROO Reminder Bot Readme - -This bot is designed to help remind users to perform certain actions related to Leppa Berries and Gracidea Flowers in PokeMMO. It uses Discord's API to communicate with users and schedule reminders. - -Usage -This bot has the following commands: - -!leppa -Reminds the user to harvest their Leppa Berries in 20 hours. - -Example usage: !leppa - -!gracidea -Reminds the user to harvest their Gracidea Flowers in 44 hours. - -Example usage: !gracidea - -!water duration -Reminds the user to water their berries after a specified duration (in hours). - -Example usage: !water 6 - -This will remind the user to water their berries in 6 hours. - -!reminders -Lists all of the user's active reminders. - -Example usage: !reminders - -!cancel @user -Cancels all of the specified user's active reminders. - -Example usage: !cancel @example-user - diff --git a/berry_bot.py b/berry_bot.py index 216fba3..ca805b0 100644 --- a/berry_bot.py +++ b/berry_bot.py @@ -3,11 +3,15 @@ import datetime from discord.ext import commands +# Initialize intents and bot intents = discord.Intents.all() intents.members = True bot = commands.Bot(command_prefix='!', intents=intents) + +# Initialize reminders dictionary reminders = {} +# Callback functions for reminders async def remind_leppa(member): await asyncio.sleep(60) await member.send(f'{member.mention} time to harvest your Leppa Berries!') @@ -20,20 +24,22 @@ async def remind_gracidea(member): if member.id in reminders: reminders[member.id].pop("gracidea", None) +# Function to schedule reminders async def schedule_reminder(member, delay, callback, reminder_name): - # Schedule the reminder to be sent after the specified delay await asyncio.sleep(delay) await callback(member) # Remove the reminder from the dictionary after it has been completed if member.id in reminders: reminders[member.id].pop(reminder_name, None) - + +# Event to print bot's login name @bot.event async def on_ready(): print(f'Logged in as {bot.user.name}') +# Command to set a Leppa Berry reminder @bot.command() async def leppa(ctx): delay = 20 * 60 * 60 # 20 hours in seconds @@ -44,6 +50,7 @@ async def leppa(ctx): reminders[member.id]["leppa"] = datetime.datetime.now() + datetime.timedelta(seconds=delay) await schedule_reminder(member, delay, remind_leppa, "leppa") +# Command to set a Gracidea Flower reminder @bot.command() async def gracidea(ctx): delay = 44 * 60 * 60 # 44 hours in seconds @@ -54,6 +61,7 @@ async def gracidea(ctx): reminders[member.id]["gracidea"] = datetime.datetime.now() + datetime.timedelta(seconds=delay) await schedule_reminder(member, delay, remind_gracidea, "gracidea") +# Command to set a custom water reminder @bot.command() async def water(ctx, duration: int): delay = duration * 60 * 60 # Convert hours to seconds @@ -66,6 +74,7 @@ async def water(ctx, duration: int): reminders[member.id]["water"] = due_time # Use the due time instead of current server time await schedule_reminder(member, delay, lambda m: m.send(f"{m.mention} it's time to water your berries!"), "water") +# Command to list all active reminders @bot.command(name='reminders', help='Lists all the active reminders') async def list_reminders(ctx): member = ctx.author @@ -94,6 +103,7 @@ async def list_reminders(ctx): else: await ctx.send(f"{member.mention}, you do not have any active reminders.") +# Command to cancel all of a user's reminders @bot.command(name='cancel', help='Cancels the specified user\'s reminder') async def cancel(ctx, member: discord.Member): try: