Skip to content

docs: Add additional documentation #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <duration>`: 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`




34 changes: 0 additions & 34 deletions README.txt

This file was deleted.

14 changes: 12 additions & 2 deletions berry_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!')
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down