예제 #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()
예제 #2
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
예제 #3
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"))
예제 #4
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)))
예제 #5
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'))
예제 #6
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!'))
예제 #7
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!'))
예제 #8
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"))
예제 #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"))
예제 #10
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