async def add(self, ctx, username: typing.Optional[str]): await ctx.message.delete() whitelistLogChannel = self.bot.get_channel( int(os.getenv("WHITELIST_LOG_CHANNEL_ID"))) activityData = await activityCollection.find_one({"_id": "envision"}) memberData = await memberCollection.find_one({"_id": "envision"}) if username == None: try: await ctx.channel.send( f"What username do you want to add to the whitelist?") username = (await self.bot.wait_for( "message", timeout=300, check=messageCheck(ctx))).content.casefold() except asyncio.TimeoutError: await ctx.channel.send(f"Timed out") username = username.casefold() if username not in [ member["username"] for member in memberData["members"].values() ]: await ctx.channel.send( f"That member is not in the guild. Are you sure you spelled their name correctly? If you are sure you spelled their name correctly and that they are in the guild, wait a few minutes and try again. The cache updates every 5 minutes." ) return unwhitelistDate = datetime.datetime.now().astimezone(eastern).replace( hour=0, minute=0, second=0, microsecond=0) + datetime.timedelta( days=activityData["whitelistDuration"]) activityCollection.update_one({"_id": "envision"}, { "$push": { "whitelist": { "username": username, "unwhitelistDate": unwhitelistDate } } }) await ctx.channel.send( f"<:added:835599921113202688> **{username}** added to whitelist on **{datetime.datetime.now().astimezone(eastern).date().strftime('%m/%d/%Y')}** (Unwhitelisted on **{unwhitelistDate.date().strftime('%m/%d/%Y')}**) **|** Added by {ctx.author}" ) if ctx.channel != whitelistLogChannel: await whitelistLogChannel.send( f"<:added:835599921113202688> **{username}** added to whitelist on **{datetime.datetime.now().astimezone(eastern).date().strftime('%m/%d/%Y')}** (Unwhitelisted on **{unwhitelistDate.date().strftime('%m/%d/%Y')}**) **|** Added by {ctx.author}" )
async def requirement(self, ctx, amount: typing.Optional[int]): """ Sets the weekly member gexp requirement Parameters: amount (int): the amount of gexp required to pass the inactivity check. Usage: o![whitelist|white|wl|w] [requirement|reqs|req] [amount] Example: o!w req 120000 >> sets activity requirement to 120,000 gexp """ await ctx.message.delete() activityLogChannel = self.bot.get_channel( int(os.getenv("ACTIVITY_LOG_CHANNEL_ID"))) if amount == None: try: await ctx.channel.send( f"What amount fo gexp do you want to set the weekly requirement to?", delete_after=15) amountResponse = await self.bot.wait_for( "message", timeout=300, check=messageCheck(ctx)) await amount.delete() amount = int(amountResponse.content) except asyncio.TimeoutError: await ctx.channel.send(f"Timed Out", delete_after=15) return except ValueError: await ctx.channel.send(f"Amount must be an integer", delete_after=15) return activityCollection.update_one({"_id": "envision"}, {"$set": { "weeklyReq": amount }}) await ctx.channel.send( f"<:exp:835707034611220541> Weekly gexp requirement set to **{amount}** by {ctx.author}" ) if ctx.channel != activityLogChannel: await activityLogChannel.send( f"<:exp:835707034611220541> Trial gexp requirement set to **{amount}** by {ctx.author}" )
async def remove(self, ctx, username: typing.Optional[str]): await ctx.message.delete() whitelistLogChannel = self.bot.get_channel( int(os.getenv("WHITELIST_LOG_CHANNEL_ID"))) activityData = await activityCollection.find_one({"_id": "envision"}) whitelistedMembers = [ member["username"] for member in activityData["whitelist"] ] if username == None: try: await ctx.channel.send( f"What username do you want to remove from the whitelist?") username = (await self.bot.wait_for( "message", timeout=300, check=messageCheck(ctx))).content.casefold() except asyncio.TimeoutError: await ctx.channel.send(f"Timed out") username = username.casefold() if username not in whitelistedMembers: await ctx.channel.send(f"That member is not ont he waitlist.") return activityCollection.update_one( {"_id": "envision"}, {"$pull": { "whitelist": { "username": username } }}) await ctx.channel.send( f"<:removed:835599920860758037> **{username}** removed from whitelist **|** removed by {ctx.author}" ) if ctx.channel != whitelistLogChannel: await whitelistLogChannel.send( f"<:removed:835599920860758037> **{username}** removed from whitelist **|** removed by {ctx.author}" )
async def duration(self, ctx, duration: typing.Optional[int]): await ctx.message.delete() whitelistLogChannel = self.bot.get_channel( int(os.getenv("WHITELIST_LOG_CHANNEL_ID"))) if duration == None: try: await ctx.channel.send( f"How long do you want to set the whitelist time to be?", delete_after=15) durationResponse = await self.bot.wait_for( "message", timeout=300, check=messageCheck(ctx)) await durationResponse.delete() duration = int(durationResponse.content) except asyncio.TimeoutError: await ctx.channel.send(f"Timed out", delete_after=15) return except ValueError: await ctx.channel.send(f"The duration must be an integer.", delete_after=15) return activityCollection.update_one( {"_id": "envision"}, {"$set": { "whitelistDuration": duration }}) await ctx.channel.send( f"🕐 Whitelist duration set to **{duration}** days by {ctx.author}") if ctx.channel != whitelistLogChannel: await whitelistLogChannel.send( f"🕐 Whitelist duration set to **{duration}** days by {ctx.author}" )
async def updateWhitelist(self): activityData = await activityCollection.find_one({"_id": "envision"}) whitelist = activityData["whitelist"] now = datetime.datetime.now().astimezone(eastern) whitelistLogChannel = self.bot.get_channel( int(os.getenv("WHITELIST_LOG_CHANNEL_ID"))) for member in whitelist: if member["unwhitelistDate"].date() == now.date(): await whitelistLogChannel.send( f"Member {member['username']} unwhitelisted. Reached the end of their whitelist time." ) activityCollection.update_one( {"_id": "envision"}, {"$pull": { "whitelist": { "username": member["username"] } }})