Skip to content

Commit

Permalink
Add clan apply command (#80)
Browse files Browse the repository at this point in the history
Add new command clan apply to streamline the clan member application
process. This allows a registered user to send an application in the
form of a embed message to a channel that has been designated by server
managers to receive admin notifications.

An admin can then react to this message with either a ✅ or ❌ to
approve or deny the request. An approval will send a clan invite using
the Destiny API and inform the user via DM, denials will only send a DM.

Any pending applications can be recalled using the command clan applied
(as clan pending is used for pending clan invites in the Destiny API)
which then become the canonical messages for reaction based approvals.
Previous messages are deleted to prevent confusion.
  • Loading branch information
henworth authored Apr 30, 2021
1 parent e3ab9fb commit 7b41a83
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 240 deletions.
18 changes: 16 additions & 2 deletions seraphsix/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
InvalidCommandError, InvalidGameModeError, InvalidMemberError,
NotRegisteredError, ConfigurationError, MissingTimezoneError, MaintenanceError)
from seraphsix.tasks.core import create_redis_jobs_pool
from seraphsix.tasks.clan import ack_clan_application
from seraphsix.tasks.discord import store_sherpas, update_sherpa

log = logging.getLogger(__name__)
intents = discord.Intents.default()
intents.members = True
intents.reactions = True

STARTUP_EXTENSIONS = [
'seraphsix.cogs.clan', 'seraphsix.cogs.game', 'seraphsix.cogs.member',
Expand Down Expand Up @@ -148,7 +150,7 @@ async def process_tweet(self, tweet):
async def track_tweets(self):
stream = self.twitter.stream.statuses.filter.post(follow=constants.TWITTER_FOLLOW_USERS)
async for tweet in stream:
if peony.events.tweet(tweet):
if peony.events.tweet(tweet) and not peony.events.retweet(tweet):
if tweet.in_reply_to_status_id:
continue
# For some reason non-followed users sometimes sneak into the stream
Expand All @@ -159,7 +161,7 @@ async def track_tweets(self):
async def connect_redis(self):
self.redis = await aioredis.create_redis_pool(self.config.redis_url)
self.ext_conns['redis_cache'] = self.redis
self.ext_conns['redis_jobs'] = await create_redis_jobs_pool(self.config.arq_redis)
self.ext_conns['redis_jobs'] = await create_redis_jobs_pool()

@tasks.loop(hours=1.0)
async def cache_clan_members(self):
Expand All @@ -183,6 +185,13 @@ async def on_connect(self):
await self.connect_redis()

async def on_ready(self):
guilds = await self.ext_conns['database'].execute(Guild.select())
if not guilds:
return
self.guild_map = {}
for guild in guilds:
self.guild_map[guild.guild_id] = guild

self.log_channel = self.get_channel(self.config.log_channel)
self.reg_channel = self.get_channel(self.config.reg_channel)

Expand All @@ -203,6 +212,11 @@ async def on_member_update(self, before, after):
if not before.bot:
await update_sherpa(self, before, after)

async def on_raw_reaction_add(self, payload):
if payload.channel_id == self.guild_map[payload.guild_id].admin_channel and \
payload.emoji.name in [constants.EMOJI_CHECKMARK, constants.EMOJI_CROSSMARK]:
await ack_clan_application(self, payload)

async def on_guild_join(self, guild):
await self.log_channel.send(f"Seraph Six joined {guild.name} (id:{guild.id})!")

Expand Down
Loading

0 comments on commit 7b41a83

Please sign in to comment.