Skip to content

Conversation

@RohanJnr
Copy link
Member

@RohanJnr RohanJnr commented Nov 2, 2020

closes #1172

This PR uses the new API endpoints and features implemented in python-discord/site#410
Hence, this PR should be merged only after the Site PR is merged and deployed.

Commands/Functionality the Cog provides:

  • Create a new user event.
  • Delete user event.
  • Schedule a user event.
  • Cancel scheduled user event.
  • Open/Close user events voice channel.
  • Announce during event start by tagging all event subscribers.
  • Modify user event description.

How does this work?

  • Whenever a new user event is created, it will be listed in a new channel called #user-events-list (name can be flexible). This channel is used to display all the user events and also show their status such as:

    • Scheduled on DateTime in readable format
    • Not Scheduled
    • Live
      image
      image
  • The event message ID will be stored in the site DB for further usage.

  • Users will be able to subscribe to the event by reacting to the ✔️ reaction on the message.

  • When the user event is scheduled, the status in the event message is edited.
    image
    image

Also, another message is sent in the #user-event-announcement channel, like the one below:
image

  • 30min before the event start time, the organizer is given the ongoing role and has access to commands to open/close the user event voice channel and also the announce command.

Conditions

  • 2 Events with the same name cannot exist.
  • An organizer cannot have multiple events scheduled.
  • No two events can overlap (in terms of time).
  • There must be a minimum of 30min gap between 2 scheduled events.

Note: All the above checks are handled by the site in form of validation checks, the bot just catches the ResponseCodeError exception.

Channels used

  • #use-events-list(need to be created)
  • #user-event-announcements
  • #user-event-coordinators(need to be created-not sure if its already present)

Roles used

  • Developers role(verified role)
  • user_event_coordinator
  • user_event_ongoing

@RohanJnr RohanJnr force-pushed the user_events_management branch from f642bdb to 73174ad Compare November 6, 2020 15:12
@RohanJnr RohanJnr marked this pull request as ready for review November 6, 2020 15:21
@RohanJnr RohanJnr requested a review from a team as a code owner November 6, 2020 15:21
@RohanJnr RohanJnr requested review from kosayoda and lemonsaurus and removed request for a team November 6, 2020 15:21
@ghost ghost added the needs 2 approvals label Nov 6, 2020
Copy link
Member

@ks129 ks129 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of reviews

if not self.check_if_user_is_organizer(ctx.author.id, event_name):
await ctx.send("You can only modify your events!")
return
data = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this 1 key to call and don't assign it to variable.

@ghost ghost added s: waiting for author Waiting for author to address a review or respond to a comment and removed needs 2 approvals labels Nov 6, 2020
@ghost ghost removed the s: waiting for author Waiting for author to address a review or respond to a comment label Nov 6, 2020
@ghost ghost added s: waiting for author Waiting for author to address a review or respond to a comment and removed needs 2 approvals labels Nov 14, 2020
@ghost ghost added needs 2 approvals and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Nov 21, 2020
@coveralls
Copy link

coveralls commented Nov 23, 2020

Coverage Status

Coverage decreased (-0.5%) to 56.003% when pulling 6137d45 on RohanJnr:user_events_management into 7aec121 on python-discord:master.

@RohanJnr RohanJnr requested a review from ks129 November 23, 2020 15:24
Comment on lines +61 to +68
self.user_event_coord_channel = None
self.user_event_announcement_channel = None
self.user_events_list_channel = None
self.user_event_voice_channel = None

# Load required roles.
self.developers_role = None
self.user_event_ongoing_role = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is place where adding type hint to variable is good.

Comment on lines +85 to +92
self.user_event_coord_channel = self.bot.get_channel(Channels.user_event_coordinators)
self.user_event_announcement_channel = self.bot.get_channel(Channels.user_event_announcements)
self.user_events_list_channel = self.bot.get_channel(Channels.user_event_list)
self.user_event_voice_channel = self.bot.get_channel(Channels.user_event_voice)

# Load required roles.
self.developers_role = self.guild.get_role(Roles.verified)
self.user_event_ongoing_role = self.guild.get_role(Roles.user_event_ongoing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use here get or fetch pattern. When some channel/role is not found, this should unload cog and show warning about it, because everything is required there. Also, use asyncio.Event to wait for items loading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discordpy does not provide the fetch method for channels.
I am going for the following pattern:

  • using properties like before
  • add a custom property decorator that caches the value and unloads the cog if the property value is None.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discord.py have fetch_channel method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right, how did I miss that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if I check if get_channel or get_role returns None, then I unload the cog with appropriate logging instead of fetch_channel raising an error and unloading the cog?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must be ready that channels or role(s) is not in cache, so we need to fetch them.

@ghost ghost added s: waiting for author Waiting for author to address a review or respond to a comment and removed needs 2 approvals labels Nov 23, 2020
}

NOT_SCHEDULED = "Not scheduled"
LIVE = "Live"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a constant, if it's only used once?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings had getter functions before, I asked moving them from functions to constants.

@Xithrius Xithrius added a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 3 - low Low Priority t: feature New feature or request labels Feb 25, 2021
@Xithrius
Copy link
Member

Xithrius commented Feb 25, 2021

Current state of this PR: Organization Issue.

@janine9vn what would you like to do with this PR? I believe you had some suggestions/plans?

@Xithrius Xithrius added s: deferred Will be done at a later time and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Feb 25, 2021
Base automatically changed from master to main March 13, 2021 19:40
@janine9vn
Copy link
Contributor

I've chatted with @RohanJnr about converting this code for a different but very similar purpose. He'll be using a new branch and PR but has requested this stay open for a bit longer to reference some implementation details.

@Xithrius
Copy link
Member

@janine9vn Thank you for the update.

@Xithrius
Copy link
Member

Xithrius commented Jun 4, 2021

@RohanJnr do you still need this PR to exist?

@RohanJnr
Copy link
Member Author

RohanJnr commented Jun 6, 2021

Closing this as a new one will be opened for #1603 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 3 - low Low Priority s: deferred Will be done at a later time t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User Events Management System

5 participants