Exemple #1
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()
Exemple #2
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"))
Exemple #3
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)
Exemple #4
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'))
    async def on_command_error(self, ctx, error):

        if hasattr(ctx.command, 'on_error'):
            return

        ignored = (commands.CommandNotFound, commands.NoPrivateMessage,
                   commands.DisabledCommand, discord.NotFound,
                   commands.CheckFailure)
        error = getattr(error, "original", error)

        if isinstance(error, ignored):
            return
        elif isinstance(error, commands.BadArgument):
            return await ctx.send(embed=func.ErrorEmbed(
                self, ctx.guild.id,
                Language.get(ctx.guild.id, self.bot.cache, "Errors",
                             "BadArgument")),
                                  delete_after=15)

        elif isinstance(error, discord.Forbidden):
            try:
                return await ctx.send(embed=func.ErrorEmbed(
                    self, ctx.guild.id,
                    Language.get(ctx.guild.id, self.bot.cache, "Errors",
                                 "Forbidden")),
                                      delete_after=15)
            except discord.Forbidden:
                return

        elif isinstance(error, commands.MissingPermissions):
            try:
                return await ctx.send(embed=func.ErrorEmbed(
                    self, ctx.guild.id,
                    Language.get(ctx.guild.id, self.bot.cache, "Errors",
                                 "MissingPermissions")),
                                      delete_after=15)
            except discord.Forbidden:
                return

        elif isinstance(error, commands.CommandOnCooldown):
            return await ctx.send(embed=func.ErrorEmbed(
                self, ctx.guild.id, "{}! {}".format(
                    ctx.author.mention,
                    Language.get(ctx.guild.id, self.bot.cache, "Errors",
                                 "Cooldown"))),
                                  delete_after=15)

        await self.Errorlog(ctx, error)
Exemple #6
0
    async def access(self, ctx):

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

        await ctx.send(embed=func.ErrorEmbed(
            f"Usage:\n\n{ctx.prefix}access add @user [Type]\n{ctx.prefix}access remove @user\n{ctx.prefix}access list\n\n Access Types: admin & owner"
        ))
Exemple #7
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"))
Exemple #8
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)
Exemple #9
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"))
Exemple #10
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")
Exemple #11
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
Exemple #12
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)
 async def Errorlog(self, ctx, error):
     errorschan = await self.bot.fetch_channel(705956719531917314)
     await errorschan.send(embed=func.ErrorEmbed(self, ctx, str(error)))