Ejemplo n.º 1
0
    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}"
            )
Ejemplo n.º 2
0
    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}"
            )
Ejemplo n.º 3
0
    async def reload(self, ctx, extension: typing.Optional[str] = None):

        if extension == None:

            await ctx.channel.send(f"what cog do you want to reload?")
            extension = (await
                         self.bot.wait_for(f"message",
                                           timeout=300,
                                           check=messageCheck(ctx))).content

        self.bot.reload_extension(F"extensions.{extension}")
Ejemplo n.º 4
0
    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}"
            )
Ejemplo n.º 5
0
    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}"
            )
Ejemplo n.º 6
0
    async def requirements(self, ctx, amount: typing.Optional[int]):

        """
        Sets the trial member gexp requirement

        Parameters:
            amount (int): the amount of gexp required to pass the trial period

        Usage:
            o![trials|trial|t] [requirements|requirement|reqs|req] [amount]

        Example:
            o!trial req 200000 >> sets trial requirement to 200,000 gexp
        """

        await ctx.message.delete()

        trialDateChannel = self.bot.get_channel(int(os.getenv("TRIAL_MEMBER_DATE_CHANNEL_ID")))

        try:

            if amount == None:

                await ctx.channel.send(f"What do you want to set the gexp requirement for trial members to?", delete_after = 15)
                amountQuestionResponse = await self.bot.wait_for("message", timeout = 300, check = messageCheck(ctx))
                await amountQuestionResponse.delete()
                amount = int(amountQuestionResponse.content)

        except asyncio.TimeoutError:

            await ctx.channel.send(f"Timed out.", delete_after = 15)
            return

        except ValueError:

            await ctx.channel.send(f"Gexp requirement amount needs to be an integer.", delete_after = 15)
            return

        await trialsCollection.update_one({"_id": "envision"}, {"$set": {"trialReq": amount}})
        await ctx.channel.send(f"<:exp:835707034611220541> Trial gexp requirement set to **{amount}** by {ctx.author}")

        if ctx.channel != trialDateChannel:

            await trialDateChannel.send(f"<:exp:835707034611220541> Trial gexp requirement set to **{amount}** by {ctx.author}")
Ejemplo n.º 7
0
    async def extend(self, ctx, username: typing.Optional[str], duration: typing.Optional[int]):

        await ctx.message.delete()

        trialData = await trialsCollection.find_one({"_id": "envision"})
        trialMembers = trialData["trialMembers"]

        trialMemberLogChannel = self.bot.get_channel(int(os.getenv("TRIAL_MEMBER_DATE_CHANNEL_ID")))

        if username == None:

            try:

                await ctx.channel.send(f"What member's trial period time do you want to extend?", delete_after = 15)
                usernameResponse = await self.bot.wait_for("message", timeout = 300, check = messageCheck(ctx))
                await usernameResponse.delete()
                username = usernameResponse.content

            except asyncio.TimeoutError:

                await ctx.channel.send(f"Timed out", delete_after = 15)
                return

        username = username.casefold()

        if username not in [member["username"] for member in trialMembers]:

            await ctx.channel.send(f"That member is not on their trial period. You can start their trial period with 'o!trials add {username}'.", delete_after = 15)
            return

        if duration == None:

            try:

                await ctx.channel.send(f"How many days do you want to extend their trial by?", 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"Extension duration must be an integer.", delete_after = 15)
                return

        memberDate = next(trial["memberDate"] for trial in trialMembers if trial["username"] == username) + datetime.timedelta(days = duration)

        await trialsCollection.update_one({"_id": "envision", "trialMembers.username": username}, {"$set": {"trialMembers.$.memberDate": memberDate}})
        await ctx.channel.send(f"<:extend:835734028497321984> **{username}** trial period extended by **{duration}** days **|** Member on **{memberDate.strftime('%m/%d/%Y')}** (mm/dd/yy) **|** Extended by by {ctx.author}")

        if ctx.channel != trialMemberLogChannel:

            await trialMemberLogChannel.send(f"<:extend:835734028497321984> **{username}** trial period extended by **{duration}** days **|** Member on **{memberDate.strftime('%m/%d/%Y')}** (mm/dd/yy) **|** Extended by by {ctx.author}")
Ejemplo n.º 8
0
    async def remove(self, ctx, username: typing.Optional[str]):

        """
        Removes a member from the trial member list

        Parameters:
            username (string): the username of the trial member

        Usage:
            o![trials|trial|t] [remove|rem|r] [username]

        Example:
            o!trial rem Phidipedes >> removes the user 'Phidipedes' from the trial member list
        """

        await ctx.message.delete()

        trialDateChannel = self.bot.get_channel(int(os.getenv("TRIAL_MEMBER_DATE_CHANNEL_ID")))

        trialData = await trialsCollection.find_one({"_id": "envision"})
        trialMembers = trialData["trialMembers"]

        if username == None:

            try:

                await ctx.channel.send(f"What member do you want to remove from the trial list?", delete_after = 15)
                usernameResponseMessage = await self.bot.wait_for("message", timeout = 300, check = messageCheck(ctx))
                username = usernameResponseMessage.content.casefold()
                await usernameResponseMessage.delete()

            except asyncio.TimeoutError:

                await ctx.channel.send(f"Timed out", delete_after = 15)
                return

        username = username.casefold()

        if username not in [trial["username"] for trial in trialMembers]:

            await ctx.channel.send(f"That user is not in the trial member list. Make sure you spelled the name correctly!", delete_after = 15)
            return

        await trialsCollection.update_one({"_id": "envision"}, {"$pull": {"trialMembers": {"username": username}}})
        await ctx.channel.send(f"<:removed:835599920860758037> **{username}** removed from trial members **|** removed by {ctx.author}")

        if ctx.channel != trialDateChannel:

            await trialDateChannel.send(f"<:removed:835599920860758037> **{username}** removed from trial members **|** removed by {ctx.author}")
Ejemplo n.º 9
0
    async def add(self, ctx, username: typing.Optional[str]):

        """
        Adds a member to the trial member list

        Parameters:
            username (string): the username of the new trial member

        Usage:
            o![trials|trial|t] [add|a] [username]

        Example:
            o!trial add Phidipedes >> adds the user 'Phidipedes' to the trial member list
        """

        await ctx.message.delete()

        trialDateChannel = self.bot.get_channel(int(os.getenv("TRIAL_MEMBER_DATE_CHANNEL_ID")))

        trialData = await trialsCollection.find_one({"_id": "envision"})
        trialDuration = trialData["trialDuration"]
        memberData = await memberCollection.find_one({"_id": "envision"})
        members = memberData["members"].values()

        if username == None:

            try:
            
                await ctx.channel.send(f"What member do you want to log as trial member?", delete_after = 15)
                usernameMessage = await self.bot.wait_for("message", timeout = 300, check = messageCheck(ctx))
                username = usernameMessage.content.casefold()
                await usernameMessage.delete()

            except asyncio.TimeoutError:

                await ctx.channel.send(f"Timed out.", delete_after = 15)
                return

        username = username.casefold()

        if username not in [member["username"] for member in members]:

            await ctx.channel.send(f"That user is not in the guild. Make sure you spelled the name correctly! If you are sure you spelled the name correctly and that the member *is* in the guild, wait a few minutes and try again. The cache updates every minute with new members.", delete_after = 15)
            return

        if username in [trial["username"] for trial in (await trialsCollection.find_one({"_id": "envision"}))["trialMembers"]]:

            await ctx.channel.send(f"This member is already in their trial period.", delete_after = 15)
            return

        memberDate = datetime.datetime.now().astimezone(eastern).replace(hour = 0, minute = 0, second = 0, microsecond = 0) + datetime.timedelta(days = trialDuration)
        trialsCollection.update_one({"_id": "envision"}, {"$push": {"trialMembers": {"username": username, "memberDate": memberDate}}})
        await ctx.channel.send(f"<:added:835599921113202688> **{username}** added to trial members on **{datetime.datetime.now().astimezone(eastern).date().strftime('%m/%d/%Y')}** (Member on **{memberDate.date().strftime('%m/%d/%Y')}**) **|** Added by {ctx.author}")
        
        if ctx.channel != trialDateChannel:

            await trialDateChannel.send(f"<:added:835599921113202688> **{username}** added to trial members on **{datetime.datetime.now().astimezone(eastern).date().strftime('%m/%d/%Y')}** (Member on **{memberDate.date().strftime('%m/%d/%Y')}**) **|** Added by {ctx.author}")
Ejemplo n.º 10
0
    async def duration(self, ctx, duration: typing.Optional[int]):

        """
        Sets the trial preiod duration

        Parameters:
            days (int): the number of days that the trial period lasts

        Usage:
            o![trials|trial|t] [duration|dura|dur=] [days]

        Example:
            o!trial dura 7 >> sets trial period to 7 days
        """

        await ctx.message.delete()

        trialDateChannel = self.bot.get_channel(int(os.getenv("TRIAL_MEMBER_DATE_CHANNEL_ID")))

        if duration == None:

            try:
            
                await ctx.channel.send(f"How many days long do you want the trial period 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"You must give an integer number of days.", delete_after = 15)
                return

        await trialsCollection.update_one({"_id": "envision"}, {"$set": {"trialDuration": duration}})

        await ctx.channel.send(f"🕐 Trial duration set to **{duration}** days by {ctx.author}")

        if ctx.channel != trialDateChannel:

            await trialDateChannel.send(f"🕐 Trial duration set to **{duration}** days by {ctx.author}")
Ejemplo n.º 11
0
    async def extend(self, ctx, username: typing.Optional[str],
                     duration: typing.Optional[int]):

        await ctx.message.delete()

        activityData = await activityCollection.find_one({"_id": "envision"})
        whitelist = activityData["whitelist"]

        whitelistLogChannel = self.bot.get_channel(
            int(os.getenv("WHITELIST_LOG_CHANNEL_ID")))

        if username == None:

            try:

                await ctx.channel.send(
                    f"What member's whitelist time do you want to extend?",
                    delete_after=15)
                usernameResponse = await self.bot.wait_for(
                    "message", timeout=300, check=messageCheck(ctx))
                await usernameResponse.delete()
                username = usernameResponse.content.casefold()

            except asyncio.TimeoutError:

                await ctx.channel.send(f"Timed out", delete_after=15)
                return

        username = username.casefold()

        if username not in [member["username"] for member in whitelist]:

            await ctx.channel.send(
                f"That member is not on the whitelist. You can add them to the whitelist with 'o!whitelist add {username}'.",
                delete_after=15)
            return

        if duration == None:

            try:

                await ctx.channel.send(
                    f"How many days do you want to extend their whitelist by?",
                    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"Extension duration must be an integer.", delete_after=15)
                return

        unwhitelistDate = next(member["unwhitelistDate"]
                               for member in whitelist if member["username"] ==
                               username) + datetime.timedelta(days=duration)

        await activityCollection.update_one(
            {
                "_id": "envision",
                "whitelist.username": username
            }, {"$set": {
                "whitelist.$.unwhitelistDate": unwhitelistDate
            }})
        await ctx.channel.send(
            f"<:extend:835734028497321984> **{username}** whitelist period extended by **{duration}** days **|** Unwhitelisted on **{unwhitelistDate.strftime('%m/%d/%Y')}** (mm/dd/yy) **|** Extended by by {ctx.author}"
        )

        if ctx.channel != whitelistLogChannel:

            await whitelistLogChannel.send(
                f"<:extend:835734028497321984> **{username}** whitelist period extended by **{duration}** days **|** Unwhitelisted on **{unwhitelistDate.strftime('%m/%d/%Y')}** (mm/dd/yy) **|** Extended by by {ctx.author}"
            )