Beispiel #1
0
    async def list(self, ctx):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        channellist = open(self.SAVELOC + 'cotd.txt', 'r').read().split('\n')

        chanstr = ''

        for i in channellist:
            if i == '':
                continue
            splitted = i.split('|')

            channel = await self.bot.fetch_channel(int(splitted[0]))

            chanstr += f'{channel.mention} - {self.yesno(splitted[1])}\n'
        if chanstr != '':
            await ctx.send(embed=func.Embed(chanstr))
        else:
            await ctx.send(embed=func.Embed('The channel list is empty!'))
        return
Beispiel #2
0
    async def add(self, ctx, channel: discord.TextChannel = None):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        if not channel:
            return await ctx.send(embed=func.ErrorEmbed(
                'Please mention a channel to add to the list'))

        multiple = False

        if len(ctx.message.channel_mentions) > 1:
            multiple = True

        multilist = []

        for i in ctx.message.channel_mentions:

            channellist = open(self.SAVELOC + 'cotd.txt',
                               'r').read().split('\n')
            if str(i.id) in [i.split('|')[0] for i in channellist]:
                await ctx.send(embed=func.ErrorEmbed(
                    f'{i.mention} is already in the list, skipping..'))
                continue

            if not multiple:
                await ctx.send(embed=func.Embed(
                    f'Channel {i.mention} has been added to the list'))

            write = open(self.SAVELOC + 'cotd.txt', 'a')
            write.write(f"\n{i.id}|0")
            write.close()

            multilist.append(i)

        if multiple:
            channelmentions = ''
            for i in multilist:
                channelmentions += f'{i.mention}, '

            await ctx.send(embed=func.Embed(
                f'Channels {channelmentions} have been added to the list'))
Beispiel #3
0
    async def cog(self, ctx):
        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        await ctx.send(embed=func.Embed(
            "**cog load** - Load a cog.\n**cog unload** - Unload a cog.\n**cog reload** - Reload a cog\n**cog list** - Lists all cogs."
        ))
Beispiel #4
0
    async def remove(self, ctx, channel: discord.TextChannel = None):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        if not channel:
            return await ctx.send(embed=func.ErrorEmbed(
                'Please mention a channel to remove from the list'))

        channellist = open(self.SAVELOC + 'cotd.txt', 'r').read().split('\n')

        if str(channel.id) not in [i.split('|')[0] for i in channellist]:
            return await ctx.send(
                embed=func.ErrorEmbed(f'{channel.mention} is not in the list'))

        await ctx.send(embed=func.Embed(
            f'Channel {channel.mention} has been removed from the list'))

        st = ''
        for i in channellist:
            if i.split('|')[0] != str(channel.id):
                st += f'\n{i}'

        write = open(self.SAVELOC + 'cotd.txt', 'w')
        write.write(st)
        write.close()
Beispiel #5
0
    async def add(self, ctx, user: discord.User = None, access: str = None):

        types = ['owner', 'admin']

        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        if not user or not access:
            return await ctx.send(
                embed=func.ErrorEmbed(f"Mention a user & access rank"))

        if access not in types:
            return await ctx.send(
                embed=func.ErrorEmbed(f"Please type 'admin' or 'owner'"))

        if access == 'owner':
            type = 2

        elif access == 'admin':
            type = 1

        if not sql.isStaff(user):
            if sql.SetAccess(user, type):
                await ctx.send(
                    embed=func.Embed(f"Gave {user.mention} {access}."))
            else:
                await ctx.send(embed=func.ErrorEmbed(
                    "Something went wrong. Please try again"))
        else:
            await ctx.send(
                embed=func.ErrorEmbed("That user already has access rights"))
Beispiel #6
0
    async def reset(self, ctx):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        channellist = open(self.SAVELOC + 'cotd.txt', 'r').read().split('\n')

        msg = await ctx.send(embed=func.Embed('Resetting the list....'))

        st = ''
        for i in channellist:
            if i != '':
                try:
                    trye = await self.bot.fetch_channel(int(i.split('|')[0]))
                    st += '\n{}|0'.format(i.split('|')[0])
                except:
                    pass

        write = open(self.SAVELOC + 'cotd.txt', 'w')
        write.write(st)
        write.close()
        save = open(self.SAVELOC + 'cotdSave.txt', 'r').read().split('\n')

        try:
            returnchannel = await self.bot.fetch_channel(int(save[0]))
            returncategory = await self.bot.fetch_channel(int(save[2]))
            try:
                await returnchannel.edit(name=save[1],
                                         category=returncategory,
                                         position=int(save[3]))
            except:
                pass
        except:
            pass

        reset = open(self.SAVELOC + 'cotdSave.txt', 'w')
        reset.close()

        await msg.edit(embed=func.Embed('The list has been resetted!'))
Beispiel #7
0
    async def list(self, ctx):
        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        cogs = []
        for file in os.listdir("modules"):
            if file.endswith(".py"):
                name = file[:-3]
                cogs.append(name)
        await ctx.send(embed=func.Embed("\n".join(cogs)))
Beispiel #8
0
    async def load(self, ctx, cog: str = None):
        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        if not cog:
            await ctx.send(embed=func.ErrorEmbed("Please name a cog to load"))

        try:
            self.bot.load_extension(f"modules.cogs.{cog}")
            await ctx.send(embed=func.Embed(f"{cog} was successfully loaded."))
        except Exception as error:
            await ctx.send(embed=func.ErrorEmbed(f"{cog} failed to load"))
            await ctx.author.send(error)
Beispiel #9
0
    async def list(self, ctx):
        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        supporter_roles = sql.getSupportRoles()

        roless = []

        for i in supporter_roles:
            role = discord.utils.get(ctx.guild.roles, id=int(i))

            roless.append(role.name)

        await ctx.send(embed=func.Embed("\n".join(roless)))
Beispiel #10
0
    async def clear(self, ctx):

        if not await sql.isSupporter(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        if ctx.channel.id != self.spam_id:
            return await self.spam.send(f"{ctx.author.mention} Try here",
                                        delete_after=30)

        for roles in ctx.author.roles:
            if roles.id in self.color_roles:
                role = discord.utils.get(ctx.guild.roles, id=roles.id)
                await ctx.author.remove_roles(role)

        embed = func.Embed(f"**{ctx.author.name}** Cleared their color roles!")
        await ctx.send(embed=embed)
Beispiel #11
0
    async def removeall(self, ctx):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        write = open(self.SAVELOC + 'cotd.txt', 'w')
        write.write('')
        write.close()

        await ctx.send(embed=func.Embed('The list has been cleared!'))
Beispiel #12
0
    async def channel(self, ctx):

        if not ctx.guild:
            return

        if ctx.invoked_subcommand is None:
            page = f"""
            `{ctx.prefix}channel add` - adds a channel to the list of cotd choices
            `{ctx.prefix}channel remove` - removes a channel from the list of cotd choices
            `{ctx.prefix}channel list` - lists the current cotd choices
            `{ctx.prefix}channel removeall` - clears the cotd choicelist
            `{ctx.prefix}channel reset` - resets the channels
            `{ctx.prefix}channel choosenow` - Chooses a cotd channel immediately
            """

            await ctx.send(embed=func.Embed(page))
Beispiel #13
0
    async def remove(self, ctx, user: discord.User = None):

        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        if not user:
            return await ctx.send(embed=func.ErrorEmbed(f"Mention a user"))

        if sql.isStaff(user):
            if sql.DelAccess(user):
                await ctx.send(
                    embed=func.Embed(f"Removed {user.mention}'s rights"))
            else:
                await ctx.send(embed=func.ErrorEmbed(
                    "Something went wrong. Please try again"))
        else:
            await ctx.send(
                embed=func.ErrorEmbed("That user has no access rights"))
Beispiel #14
0
    async def unload(self, ctx, cog: str = None):
        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        if not cog:
            return await ctx.send(
                embed=func.ErrorEmbed("Please name a cog to load"))

        if cog == "Commands":
            return await ctx.send(
                embed=func.ErrorEmbed("That is a required cog. Try another"))

        try:
            self.bot.unload_extension(f"modules.{cog}")
            await ctx.send(
                embed=func.Embed(f"{cog} was successfully unloaded."))
        except Exception as error:
            await ctx.send(embed=func.ErrorEmbed(f"{cog} failed to unload"))
            func.log(error)
Beispiel #15
0
    async def remove(self, ctx, roleid: int = None):
        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        if not roleid:
            return await ctx.send(
                embed=func.ErrorEmbed(f"Please provide me with a role ID"))

        role = discord.utils.get(ctx.guild.roles, id=roleid)

        if not role:
            return await ctx.send(
                embed=func.ErrorEmbed("I couldnt find that role"))

        if sql.delSupportRole(roleid):
            await ctx.send(
                embed=func.Embed(f"Removed {role.name} from the database"))
        else:
            await ctx.send(
                embed=func.ErrorEmbed("That role is not in the database"))
Beispiel #16
0
    async def mentions(self, ctx, tier: int = None, role: int = None):
        if not role or not tier:
            await ctx.send(embed=func.Embed(
                f"Use the command like this:\n\n{ctx.prefix}mentions [5 / 6] [roleid]"
            ))

        if tier < 5:
            return

        check = discord.utils.get(ctx.guild.roles, id=role)

        if not check:
            return await ctx.send(
                embed=func.ErrorEmbed("I couldnt find that role"))

        self.roles[f"Tier{tier}"] = role
        with open("./modules/data/cards/MentionRoles.json", "w") as f:
            json.dump(self.roles, f)

            await ctx.send("Updated")
Beispiel #17
0
    async def list(self, ctx):

        if not sql.isOwner(ctx.author.id):
            return await ctx.send(embed=func.NoPerm())

        unformatted = sql.getallAccess()

        formatted = []

        for i in unformatted:
            user = await self.bot.fetch_user(i[0])

            if i[1] == 1:
                type = "Admin Access"

            if i[1] == 2:
                type = "Owner Access"

            formatted.append(f"{user.mention} - {type}")

        await ctx.send(embed=func.Embed("\n".join(formatted)))
Beispiel #18
0
    async def shoob(self, ctx, event=None, duration=None, *args):

        if not await sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        if not event or not duration or not args:
            return await ctx.send(embed=func.Embed(
                f"If you want to start an event use the command like this:\n\n{ctx.prefix}shoob event [duration] [card]\n\nDurations: m, h, d, w"
            ))

        self.event["Reward"] = ' '.join(args)
        self.event["TotalDuration"] = self.timeformat(duration)
        self.event["Remaining"] = self.event["TotalDuration"]
        self.channel = ctx.channel

        embed = await self.EventMessage()
        self.event_message = await ctx.send(embed=embed)
        self.event["Started"] = True

        embed = await self.leaderboardsMessage()
        self.leaderboard_message = await ctx.send(embed=embed)
Beispiel #19
0
    async def on_message(self, message):

        if message.channel.id != self.network_chat_id:
            return

        if message.author.id != self.shoob_id:
            return

        # Claiming -------------------------------------

        for embed in message.embeds:
            embed = embed.to_dict()

            try:
                if "To claim, use:" in embed["description"]:
                    self.card_id = message.id
                    self.most_recent_card_name = embed['title'][:embed['title']
                                                                .index("Tier")]
                    tier = embed['title'].split(":")
                    self.most_recent_tier = tier[1].replace(" ", "")
                    sql.AddCard(self.card_id, self.most_recent_card_name,
                                tier[1], datetime.datetime.utcnow(),
                                embed['image']['url'])
                    if int(tier[1]) > 4:
                        await self.MentionRoles(message,
                                                self.most_recent_card_name,
                                                tier[1])

                if f"got the card! `{self.most_recent_card_name[:-1]}`" in embed[
                        "description"]:
                    version = embed['description'].split(":")
                    ver = version[3].split(".")
                    v = ver[0].replace("`", "")
                    numbers = re.findall(r'[0-9]+', embed['description'])

                    if self.event["Started"]:
                        sql.CardClaimed(self.card_id, numbers[1], v,
                                        datetime.datetime.utcnow(), True)
                    else:
                        sql.CardClaimed(self.card_id, numbers[1], v,
                                        datetime.datetime.utcnow())

                    user = await self.bot.fetch_user(numbers[1])

                    if not sql.accountExists(user.id):
                        return await user.send(embed=func.ErrorEmbed(
                            f"Hey! You claimed a card but dont have a sCoin account? What are you doing!? Join now by typing h.sCoin in MAL."
                        ))

                    useracc = sql.getAccount(user.id)
                    amount = 0.02 * float(self.most_recent_tier)
                    sql.setCoins(user.id, float(useracc[2]) + amount)

                    sql.sLog(
                        message.author.id, 3,
                        f"Added {amount} to {message.author.name}s eCoin balance",
                        datetime.datetime.utcnow())
                    await message.channel.send(embed=func.Embed(
                        f"{user.mention} Gained {amount} sCoin for claiming {self.most_recent_card_name}: Tier {self.most_recent_tier}!"
                    ))

            except Exception as e:
                print(e)
Beispiel #20
0
    async def _choosenow(self, ctx):

        if not ctx.guild:
            return

        if not ctx.guild.id == self.MAL_ID:
            return

        if not sql.isStaff(ctx.author):
            return await ctx.send(embed=func.NoPerm())

        chooselist = []

        channellist = open(self.SAVELOC + 'cotd.txt', 'r').read().split('\n')

        for i in channellist:
            if '|0' in i:
                chooselist.append(int(i.split('|')[0]))

        save = open(self.SAVELOC + 'cotdSave.txt', 'r').read().split('\n')

        if chooselist == []:
            try:
                returnchannel = await self.bot.fetch_channel(int(save[0]))
                returncategory = await self.bot.fetch_channel(int(save[2]))
                await ctx.send(embed=func.ErrorEmbed(
                    'Cant choose from complete or empty list'))
                try:
                    await returnchannel.edit(name=save[1],
                                             category=returncategory,
                                             position=int(save[3]))
                except:
                    pass
            except:
                pass

            channellist = open(self.SAVELOC + 'cotd.txt',
                               'r').read().split('\n')

            st = ''
            for i in channellist:
                if i != '':
                    st += '\n{}|0'.format(i.split('|')[0])

            write = open(self.SAVELOC + 'cotd.txt', 'w')
            write.write(st)
            write.close()
            reset = open(self.SAVELOC + 'cotdSave.txt', 'w')
            reset.close()

            chooselist = []

            channellist = open(self.SAVELOC + 'cotd.txt',
                               'r').read().split('\n')

            for i in channellist:
                if '|0' in i:
                    chooselist.append(int(i.split('|')[0]))

            save = open(self.SAVELOC + 'cotdSave.txt', 'r').read().split('\n')

        channel = await self.bot.fetch_channel(int(choice(chooselist)))

        st = ''
        for i, v in enumerate(channellist):
            if v.startswith(str(channel.id)):
                channellist[i] = f'{channel.id}|1'
            st += '\n%s' % (channellist[i])

        write = open(self.SAVELOC + 'cotd.txt', 'w')
        write.write(st)
        write.close()

        if len(save) == 4:
            try:
                returnchannel = await self.bot.fetch_channel(int(save[0]))
                returncategory = await self.bot.fetch_channel(int(save[2]))
            except:
                pass
            try:
                await returnchannel.edit(name=save[1],
                                         category=returncategory,
                                         position=int(save[3]))
            except:
                pass

        new = open(self.SAVELOC + 'cotdSave.txt', 'w')
        new.write(
            f'{channel.id}\n{channel.name}\n{channel.category_id}\n{channel.position}'
        )
        new.close()

        newname = '\N{tulip}\u30FB'
        for i in channel.name:
            if i in string.ascii_letters or i == '-':
                newname += i

        try:
            await ctx.send(embed=func.Embed(f'Chose {channel.name}'))
            await channel.edit(name=newname, category=None)

            pingrole = discord.utils.get(discord.utils.get(
                self.bot.guilds, id=self.MAL_ID).roles,
                                         id=self.pingroleid)
            await pingrole.edit(mentionable=True)
            await channel.send(f'{pingrole.mention}', delete_after=2)
            await pingrole.edit(mentionable=False)
        except:
            return
Beispiel #21
0
 async def card(self, ctx):
     await ctx.send(embed=func.Embed(
         f"`{ctx.prefix}card stats @user` - Get a users cards stats\n`{ctx.prefix}card history` - View card history"
     ))