Skip to content

Conversation

@blacksmithop
Copy link
Member

  • Added command bump that makes a POST to /V1/bump with a JSON body
  • A guild cache to keep track of last bump (added to after first successful bump)
  • Remaining time for bump calculated from cooldown mapping or timedelta from API response (based on cache)
  • Command invite to 'set' the channel as the invite channel, create invite if none are found or fetch from list.

@mathisve
Copy link
Contributor

mathisve commented Oct 7, 2020

I'm not very familiar with discordpy so I'll leave the actual review up to @TrizlyBear.
But I'm quite confused about this:

GuildCache[ctx.guild.id] = -1

What is the -1 doing?

@blacksmithop
Copy link
Member Author

blacksmithop commented Oct 7, 2020

GuildCache[ctx.guild.id] = -1 is being used to identify guilds that are not part of the cache, before the bump they're assigned a value of -1 and upon api returning a 200, it is replaced with the current timestamp. Following that the bot relies on the built-in cooldown mapping instead of the api to handle cooldown.
In the scenario that bot restarted the cache would be empty, there remaining time before the next bump is obtained from the api response.
However a problem I encountered is the inability to overwrite the cooldown mapping to set the remaining time to a custom value (i.e time obtained by comparing with the timestamp from api response). Hence current implementation relies on the -1 flag to identify such cases.

@@ -0,0 +1,223 @@
from discord.ext import commands
from discord import Embed, File, TextChannel, Status, CustomActivity, ActivityType, Invite
from datetime import timedelta

Choose a reason for hiding this comment

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

Already imported below:

from datetime import datetime, timedelta

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, I'll remove that

@TrizlyBear
Copy link

Code looks good and is structured well.
Only thing I would suggest is moving the bot commands into a a sepperate cog file since you are using cogs for the error handler too. You don't have too but I'd say it's just a little more clean.
Overal everything looks pretty good and is well written.

@blacksmithop blacksmithop merged commit 1e1261c into development Oct 10, 2020
@mathisve
Copy link
Contributor

LGTM!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants