Beispiel #1
0
 async def desyncmuterole(self, ctx):
     """Menghapus send_messages, add_reactions, dan speak_overrides dari mute role (bot-admin/admin-only).
     Command ini berguna untuk mematikan sementara role mute dan dapat dinyalakan kembali dengan command `acx syncmuterole`."""
     if not await Utils.is_bot_admin_reply(ctx): return
     role = self.settings.getServerStat(ctx.guild,"MuteRole")
     if not role:
         em = discord.Embed(color = 0XFF8C00, description =  "> Tidak ada mute role yang telah di setup.\n"
                                                             "> Kamu dapat membuat memilih role dengan cara mengetik `{}setmuterole [role]`.\n"
                                                             "> Atau kamu juga dapat membuatnya yang baru dengan cara mengetik `{}createmuterole [role_name]`"
                                                             .format(ctx.prefix,
                                                                     ctx.prefix))
         em.set_footer(text = f"Request By : {ctx.author}", icon_url = f"{ctx.author.avatar_url}")
         return await ctx.send(embed=em)
     try: mute_role = ctx.guild.get_role(int(role))
     except: mute_role = None
     em = discord.Embed(color = 0XFF8C00, description =  "> Mute role sebelumnya dengan ID `{}` tidak ditemukan dalam server mu.\n"
                                                         "> Kamu dapat membuat memilih role lain cara mengetik `{}setmuterole [role]`.\n"
                                                         "> Atau kamu juga dapat membuatnya yang baru dengan cara mengetik `{}createmuterole [role_name]`")
     em.set_author(name = "Oops!", url = "https://acinonyxesports.com/", icon_url = "https://cdn.discordapp.com/attachments/518118753226063887/725569194304733435/photo.jpg")
     em.set_footer(text = f"Request By : {ctx.author}", icon_url = f"{ctx.author.avatar_url}")
     if not mute_role: return await ctx.send(embed=em)
     msg = "Syncing permissions **{}**...".format(Utils.suppressed(ctx,mute_role.name))
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     # Have a valid mute role here - let's desync our perms
     message = await ctx.send(embed = em)
     await self._sync_perms(ctx,mute_role,True)
     msg = "Role mute **{}** telah **dihapus**.".format(Utils.suppressed(ctx,mute_role.name))
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     await message.edit(embed = em)
Beispiel #2
0
 async def removegif(self, ctx, *, role: str = None):
     """Removes a role from the gif list (admin only)."""
     usage = 'Usage: `{}removegif [role]`'.format(ctx.prefix)
     if not await Utils.is_admin_reply(ctx): return
     if role == None:
         return await ctx.send(usage)
     # Name placeholder
     roleName = role
     if type(role) is str:
         if role.lower() == "everyone" or role.lower() == "@everyone":
             role = ctx.guild.default_role
         else:
             role = DisplayName.roleForName(role, ctx.guild)
     # If we're here - then the role is a real one
     promoArray = self.settings.getServerStat(ctx.guild, "GifArray")
     # Check by id first, then by name
     found_role = next(
         (x for x in promoArray if str(x["ID"]) == str(role.id)), False)
     if not found_role:
         found_role = next((x for x in promoArray
                            if x["Name"].lower() == role.name.lower()),
                           False)
     if found_role:
         promoArray.remove(found_role)
         self.settings.setServerStat(ctx.guild, "GifArray", promoArray)
         msg = '**{}** removed successfully.'.format(found_role['Name'])
         return await ctx.send(Utils.suppressed(ctx, msg))
     # If we made it this far - then we didn't find it
     msg = '**{}** not found in list.'.format(role)
     await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #3
0
	async def delhw(self, ctx, *, build = None):
		"""Removes a build from your build list."""

		if not build:
			return await ctx.send("Usage: `{}delhw [build name or number]`".format(ctx.prefix))

		buildList = self.settings.getGlobalUserStat(ctx.author, "Hardware")
		if buildList == None:
			buildList = []
		buildList = sorted(buildList, key=lambda x:x['Name'].lower())

		# Get build by name first - then by number
		for b in buildList:
			if b['Name'].lower() == build.lower():
				# Found it
				buildList.remove(b)
				if b['Main'] and len(buildList):
					buildList[0]['Main'] = True
				self.settings.setGlobalUserStat(ctx.author, "Hardware", buildList)
				msg = "{} removed!".format(b['Name'])
				return await ctx.send(Utils.suppressed(ctx,msg))
		try:
			build = int(build)-1
			if build >= 0 and build < len(buildList):
				b = buildList.pop(build)
				if b['Main'] and len(buildList):
					buildList[0]['Main'] = True
				self.settings.setGlobalUserStat(ctx.author, "Hardware", buildList)
				msg = "{} removed!".format(b['Name'])
				return await ctx.send(Utils.suppressed(ctx,msg))
		except:
			pass

		msg = "I couldn't find that build or number."
		await ctx.send(msg)
Beispiel #4
0
	async def cog_before_invoke(self, ctx):
		# We don't need to ensure extra for the following commands:
		if ctx.command.name in ("playingin","autodeleteafter","disableplay"): return
		# General checks for all music player commands - with specifics filtered per command
		# If Youtube ratelimits - you can disable music globally so only owners can use it
		player = self.bot.wavelink.get_player(ctx.guild.id)
		delay = self.settings.getServerStat(ctx.guild, "MusicDeleteDelay", 20)
		if self.settings.getGlobalStat("DisableMusic",False) and not Utils.is_owner(ctx):
			# Music is off - and we're not an owner - disconnect if connected, then send the bad news :(
			self.dict_pop(ctx)
			if player.is_connected:
				await player.destroy()
			await Message.EmbedText(title="♫ Music player is currently disabled!",color=ctx.author,delete_after=delay).send(ctx)
			raise commands.CommandError("Music Cog: Music disabled.")
		# Music is enabled - let's make sure we have the right role
		if not await self._check_role(ctx):
			raise commands.CommandError("Music Cog: Missing DJ roles.")
		# If we're just using the join command - we don't need extra checks - they're done in the command itself
		if ctx.command.name == "join": return
		# We've got the role - let's join the author's channel if we're playing/shuffling and not connected
		if ctx.command.name in ("play","shuffle") and not player.is_connected and ctx.author.voice:
			await player.connect(ctx.author.voice.channel.id)
		# Let's ensure the bot is connected to voice
		if not player.is_connected:
			await Message.EmbedText(title="♫ Not connected to a voice channel!",color=ctx.author,delete_after=delay).send(ctx)
			raise commands.CommandError("Music Cog: Not connected to a voice channel.")
		# Let's make sure the caller is connected to voice and the same channel as the bot - or a bot-admin
		if Utils.is_bot_admin(ctx): return # We good - have enough perms to override whatever
		if not ctx.author.voice or not ctx.author.voice.channel.id == int(player.channel_id):
			await Message.EmbedText(title="♫ You have to be in the same voice channel as me to use that!",color=ctx.author,delete_after=delay).send(ctx)
			raise commands.CommandError("Music Cog: Author not connected to the bot's voice channel.")
Beispiel #5
0
 async def syncmuterole(self, ctx):
     """Memastikan mute role memiliki pengaturan send_messages, add_reactions, dan speak_overrides yang di nonaktifkan dalam semua channel (bot-admin/admin only)."""
     if not await Utils.is_bot_admin_reply(ctx): return
     role = self.settings.getServerStat(ctx.guild,"MuteRole")
     if not role:
         em = discord.Embed(color = 0XFF8C00, description =  "> Tidak ada mute role yang telah di setup.\n"
                                                             "> Kamu dapat membuat memilih role dengan cara mengetik `{}setmuterole [role]`.\n"
                                                             "> Atau kamu juga dapat membuatnya yang baru dengan cara mengetik `{}createmuterole [role_name]`"
                                                             .format(ctx.prefix,
                                                                     ctx.prefix))
         em.set_footer(text = f"Request By : {ctx.author}", icon_url = f"{ctx.author.avatar_url}")
         return await ctx.send(embed=em)
     try: mute_role = ctx.guild.get_role(int(role))
     except: mute_role = None
     em = discord.Embed(color = 0XFF8C00, description =  "> Mute role sebelumnya dengan ID `{}` tidak ditemukan dalam server mu.\n"
                                                         "> Kamu dapat membuat memilih role lain cara mengetik `{}setmuterole [role]`.\n"
                                                         "> Atau kamu juga dapat membuatnya yang baru dengan cara mengetik `{}createmuterole [role_name]`")
     em.set_footer(text = f"Request By : {ctx.author}", icon_url = f"{ctx.author.avatar_url}")
     if not mute_role: return await ctx.send(embed=em)
     # Have a valid mute role here - let's sync the perms
     msg = "Syncing permissions untuk **{}**...".format(Utils.suppressed(ctx,mute_role.name))
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     message = await ctx.send(embed = em)
     await self._sync_perms(ctx,mute_role)
     msg = "mute role **{}** telah berhasil di sinkronisasi.".format(Utils.suppressed(ctx,mute_role.name))
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     await message.edit(embed = em)
Beispiel #6
0
 async def setssrole(self, ctx, *, role=None):
     """Sets the Secret Santa role, or clears it if no role passed (bot-admin only)."""
     if not self.settings.getServerStat(ctx.guild, "SSAllowed", False):
         return await ctx.send(
             "The Secret Santa module has not been allowed on this server.\nOne of my owners can enable it with `{}allowss yes`."
             .format(ctx.prefix))
     # Check if we're suppressing @here and @everyone mentions
     suppress = True if self.settings.getServerStat(
         ctx.guild, "SuppressMentions", True) else False
     # Verify perms - bot-admin
     if not await Utils.is_bot_admin_reply(ctx): return
     if role == None:
         self.settings.setServerStat(ctx.guild, "SSRole", "")
         msg = 'Secret Santa role has been *removed*.'
         return await ctx.send(msg)
     if type(role) is str:
         if role == "everyone":
             role = "@everyone"
         roleName = role
         role = DisplayName.roleForName(roleName, ctx.guild)
         if not role:
             msg = 'I couldn\'t find *{}*...'.format(roleName)
             return await ctx.send(Utils.suppressed(ctx, msg))
     # If we made it this far - then we can add it
     self.settings.setServerStat(ctx.guild, "SSRole", role.id)
     msg = 'Secret Santa role has been set to **{}**.'.format(role.name)
     return await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #7
0
 async def message(self, message):
     # Check the message and see if we should allow it
     ctx = await self.bot.get_context(message)
     if not ctx.guild:
         # Don't restrict in pm
         return
     if not ctx.command:
         # No command - no need to check
         return
     # Get the list of blocked commands
     dis_com = self.settings.getServerStat(ctx.guild, "DisabledCommands")
     if ctx.command.name in dis_com:
         # Check if we're going to override
         admin_allow = self.settings.getServerStat(ctx.guild,
                                                   "AdminDisabledAccess")
         badmin_allow = self.settings.getServerStat(ctx.guild,
                                                    "BAdminDisabledAccess")
         # Check if we're admin and bot admin
         is_admin = Utils.is_admin(ctx)
         is_badmin = Utils.is_bot_admin_only(ctx)
         # Check if we override
         if (is_admin and admin_allow) or (is_badmin and badmin_allow):
             return
         # React if needed
         to_react = self.settings.getServerStat(ctx.guild,
                                                "DisabledReactions")
         if to_react:
             await message.add_reaction("🚫")
         # We have a disabled command - ignore it
         return {'Ignore': True, 'Delete': False}
 async def addprofile(self, ctx, name=None, *, link=None):
     """Add a profile to your profile list."""
     # Remove tabs, newlines, and carriage returns and strip leading/trailing spaces from the name
     name = None if name == None else name.replace("\n", " ").replace(
         "\r", "").replace("\t", " ").strip()
     if name == None or link == None:
         msg = 'Usage: `{}addprofile "[profile name]" [link]`'.format(
             ctx.prefix)
         return await ctx.send(msg)
     itemList = self.settings.getUserStat(ctx.author, ctx.guild, "Profiles")
     if not itemList:
         itemList = []
     currentTime = int(time.time())
     item = next((x for x in itemList if x["Name"].lower() == name.lower()),
                 None)
     if item:
         msg = Utils.suppressed(
             ctx, "{}'s {} profile was updated!".format(
                 DisplayName.name(ctx.author),
                 Nullify.escape_all(item["Name"])))
         item["URL"] = link
         item["Updated"] = currentTime
     else:
         itemList.append({
             "Name": name,
             "URL": link,
             "Created": currentTime
         })
         msg = Utils.suppressed(
             ctx, "{} added to {}'s profile list!".format(
                 Nullify.escape_all(name), DisplayName.name(ctx.author)))
     self.settings.setUserStat(ctx.author, ctx.guild, "Profiles", itemList)
     await ctx.send(msg)
    async def removeprofile(self, ctx, *, name=None):
        """Remove a profile from your profile list."""
        name = None if name == None else name.replace("\n", " ").replace(
            "\r", "").replace("\t", " ").strip()
        if name == None:
            msg = 'Usage: `{}removeprofile [profile name]`'.format(ctx.prefix)
            return await ctx.send(msg)

        itemList = self.settings.getUserStat(ctx.author, ctx.guild, "Profiles")
        if not itemList or itemList == []:
            msg = '*{}* has no profiles set!  They can add some with the `{}addprofile "[profile name]" [link]` command!'.format(
                DisplayName.name(ctx.author), ctx.prefix)
            return await ctx.send(msg)
        item = next((x for x in itemList if x["Name"].lower() == name.lower()),
                    None)
        if not item:
            return await ctx.send(
                Utils.suppressed(
                    ctx, "{} not found in {}'s profile list!".format(
                        Nullify.escape_all(name),
                        DisplayName.name(ctx.author))))
        itemList.remove(item)
        self.settings.setUserStat(ctx.author, ctx.guild, "Profiles", itemList)
        await ctx.send(
            Utils.suppressed(
                ctx, "{} removed from {}'s profile list!".format(
                    Nullify.escape_all(item["Name"]),
                    DisplayName.name(ctx.author))))
Beispiel #10
0
 async def addgif(self, ctx, *, role: str = None):
     """Adds a new role to the gif list (admin only)."""
     usage = 'Usage: `{}addgif [role]`'.format(ctx.prefix)
     if not await Utils.is_admin_reply(ctx): return
     if role == None:
         return await ctx.send(usage)
     roleName = role
     if type(role) is str:
         if role.lower() == "everyone" or role.lower() == "@everyone":
             role = ctx.guild.default_role
         else:
             role = DisplayName.roleForName(roleName, ctx.guild)
         if not role:
             msg = 'I couldn\'t find *{}*...'.format(roleName)
             return await ctx.send(Utils.suppressed(ctx, msg))
     # Now we see if we already have that role in our list
     promoArray = self.settings.getServerStat(ctx.guild, "GifArray")
     if any(x for x in promoArray if str(x["ID"]) == str(role.id)):
         msg = '**{}** is already in the list.'.format(role.name)
         return await ctx.send(Utils.suppressed(ctx, msg))
     # If we made it this far - then we can add it
     promoArray.append({'ID': role.id, 'Name': role.name})
     self.settings.setServerStat(ctx.guild, "GifArray", promoArray)
     msg = '**{}** added to list.'.format(role.name)
     await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #11
0
	async def set_status(self, ctx, status, status_name="Playing", status_type=0, status_url=None):
		# Only allow owner
		if not await Utils.is_owner_reply(ctx): return

		if status == status_url == None:
			self.settings.setGlobalStat('Game',None)
			self.settings.setGlobalStat('Stream',None)
			self.settings.setGlobalStat('Type',0)
			msg = 'Removing my {} status...'.format(status_name.lower())
			message = await ctx.send(msg)
			await self._update_status()
			return await message.edit(content='{} status removed!'.format(status_name))

		if status_type == 1:
			if not status:
				return await ctx.send("You need to provide a url if streaming!")
			if not any("twitch.tv" in x.lower() for x in Utils.get_urls(ctx)):
				return await ctx.send("You need to provide a valid twitch.tv url for streaming!")

		self.settings.setGlobalStat('Game',status)
		self.settings.setGlobalStat('Stream',status_url)
		self.settings.setGlobalStat('Type',status_type)
		msg = 'Setting my {} status to *{}*...'.format(status_name.lower(), status)
		message = await ctx.send(Utils.suppressed(ctx,msg))

		await self._update_status()
		await message.edit(content='{} status set to **{}**{}!'.format(status_name,Utils.suppressed(ctx,status)," at `{}`".format(status_url) if status_url else ""))
Beispiel #12
0
    async def setxp(self, ctx, *, member=None, xpAmount: int = None):
        """Sets an absolute value for the member's xp (admin only)."""

        author = ctx.message.author
        server = ctx.message.guild
        channel = ctx.message.channel

        usage = 'Usage: `{}setxp [member] [amount]`'.format(ctx.prefix)

        # Check if we're suppressing @here and @everyone mentions
        if self.settings.getServerStat(server, "SuppressMentions"):
            suppress = True
        else:
            suppress = False

        if not await Utils.is_admin_reply(ctx): return

        if member == None:
            await ctx.message.channel.send(usage)
            return

        if xpAmount == None:
            # Check if we have trailing xp
            nameCheck = DisplayName.checkNameForInt(member, server)
            if not nameCheck or nameCheck['Member'] is None:
                nameCheck = DisplayName.checkRoleForInt(member, server)
                if not nameCheck:
                    await ctx.message.channel.send(usage)
                    return
            if "Role" in nameCheck:
                mem = nameCheck["Role"]
            else:
                mem = nameCheck["Member"]
            exp = nameCheck["Int"]
            if not mem:
                msg = 'I couldn\'t find *{}* on the server.'.format(member)
                msg = Utils.suppressed(ctx, msg)
                await ctx.message.channel.send(msg)
                return
            member = mem
            xpAmount = exp

        # Check for formatting issues
        if xpAmount == None:
            # Still no xp...
            await channel.send(usage)
            return

        if type(member) is discord.Member:
            self.settings.setUserStat(member, server, "XP", xpAmount)
        else:
            for m in ctx.guild.members:
                if member in m.roles:
                    self.settings.setUserStat(m, server, "XP", xpAmount)
        msg = '*{}\'s* xp was set to *{:,}!*'.format(DisplayName.name(member),
                                                     xpAmount)
        msg = Utils.suppressed(ctx, msg)
        await channel.send(msg)
        await CheckRoles.checkroles(member, channel, self.settings, self.bot)
Beispiel #13
0
    async def set_status(self,
                         ctx,
                         status,
                         status_name="Playing",
                         status_type=0,
                         status_url=None):
        # Only allow owner
        if not await Utils.is_owner_reply(ctx): return

        if status == status_url == None:
            self.settings.setGlobalStat('Game', None)
            self.settings.setGlobalStat('Stream', None)
            self.settings.setGlobalStat('Type', 0)
            msg = 'Removing my {} status...'.format(status_name.lower())
            em = discord.Embed(color=0XFF8C00, description=msg)
            em.set_footer(text="{}".format(ctx.author),
                          icon_url="{}".format(ctx.author.avatar_url))
            message = await ctx.send(embed=em)
            await self._update_status()
            msg = "Status {} dihapus!".format(status_name)
            em = discord.Embed(color=0XFF8C00, description=msg)
            em.set_footer(text="{}".format(ctx.author),
                          icon_url="{}".format(ctx.author.avatar_url))
            return await message.edit(embed=em)

        if status_type == 1:
            if not status:
                msg = "Kamu membutuhkan url jika mengubah mode streaming!"
                em = discord.Embed(color=0XFF8C00, description=msg)
                em.set_footer(text="{}".format(ctx.author),
                              icon_url="{}".format(ctx.author.avatar_url))
                return await ctx.send(embed=em)
            if not any("twitch.tv" in x.lower() for x in Utils.get_urls(ctx)):
                msg = "Kamu membutuhkan url dari twitch.tv untuk streaming!"
                em = discord.Embed(color=0XFF8C00, description=msg)
                em.set_footer(text="{}".format(ctx.author),
                              icon_url="{}".format(ctx.author.avatar_url))
                return await ctx.send(embed=em)

        self.settings.setGlobalStat('Game', status)
        self.settings.setGlobalStat('Stream', status_url)
        self.settings.setGlobalStat('Type', status_type)
        msg = 'Merubah status {},\nmenjadi status *{}*...'.format(
            status_name.lower(), status)
        em = discord.Embed(color=0XFF8C00, description=msg)
        em.set_footer(text="{}".format(ctx.author),
                      icon_url="{}".format(ctx.author.avatar_url))
        message = await ctx.send(embed=em)
        #message = await ctx.send(Utils.suppressed(ctx,msg))

        await self._update_status()
        msg = 'Status {} berhasil dirubah ke **{}**{}!'.format(
            status_name, Utils.suppressed(ctx, status),
            " at `{}`".format(status_url) if status_url else "")
        em = discord.Embed(color=0XFF8C00, description=msg)
        em.set_footer(text="{}".format(ctx.author),
                      icon_url="{}".format(ctx.author.avatar_url))
        await message.edit(embed=em)
Beispiel #14
0
    async def removeadmin(self, ctx, *, role: str = None):
        """Removes a role from the admin list (admin only)."""

        usage = 'Usage: `{}removeadmin [role]`'.format(ctx.prefix)

        # Check if we're suppressing @here and @everyone mentions
        if self.settings.getServerStat(ctx.message.guild, "SuppressMentions"):
            suppress = True
        else:
            suppress = False

        if not await Utils.is_admin_reply(ctx): return

        if role == None:
            await ctx.message.channel.send(usage)
            return

        # Name placeholder
        roleName = role
        if type(role) is str:
            if role.lower() == "everyone" or role.lower() == "@everyone":
                role = ctx.guild.default_role
            else:
                role = DisplayName.roleForName(role, ctx.guild)

        # If we're here - then the role is a real one
        promoArray = self.settings.getServerStat(ctx.message.guild,
                                                 "AdminArray")

        for aRole in promoArray:
            # Check for Name
            if aRole['Name'].lower() == roleName.lower():
                # We found it - let's remove it
                promoArray.remove(aRole)
                self.settings.setServerStat(ctx.message.guild, "AdminArray",
                                            promoArray)
                msg = '**{}** removed successfully.'.format(aRole['Name'])
                msg = Utils.suppressed(ctx, msg)
                await ctx.message.channel.send(msg)
                return

            # Get the role that corresponds to the id
            if role and (str(aRole['ID']) == str(role.id)):
                # We found it - let's remove it
                promoArray.remove(aRole)
                self.settings.setServerStat(ctx.message.guild, "AdminArray",
                                            promoArray)
                msg = '**{}** removed successfully.'.format(role.name)
                msg = Utils.suppressed(ctx, msg)
                await ctx.message.channel.send(msg)
                return

        # If we made it this far - then we didn't find it
        msg = '**{}** not found in list.'.format(role.name)
        msg = Utils.suppressed(ctx, msg)
        await ctx.message.channel.send(msg)
Beispiel #15
0
    async def promote(self, ctx, *, member = None):
        """Menaikan jabatan role xp member ke role xp selanjutnya(admin only)."""
        # Only allow admins to change server stats
        if not await self._can_run(ctx): return
        em = discord.Embed(color = 0XFF8C00, description =  "Menaikan jabatan role xp member ke role xp selanjutnya\n\n"
                                                            "**Panduan**\n"
                                                            "*`{}promote [member]`*"
                                                            .format(ctx.prefix))
        em.set_footer(text = "Saat mengetik command, tanda [] tidak usah digunakan.\n{}".format(ctx.author),
                      icon_url = f"{ctx.author.avatar_url}")

        if member == None:
            return await ctx.send(embed=em)

        memberName = member
        member = DisplayName.memberForName(memberName, ctx.guild)
        if not member:
            msg = Utils.suppressed(ctx, '┐( ̄ヘ ̄;)┌\nAku tidak dapat menemukan *{}*...'.format(memberName))
            em = discord.Embed(color = 0XFF8C00, description = msg)
            em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
            return await ctx.send(embed = em)

        # Get user's xp
        xp = int(self.settings.getUserStat(member, ctx.guild, "XP"))

        # Get the role list
        promoArray = self.getSortedRoles(ctx.guild)
        currentRole = self.getCurrentRoleIndex(member, ctx.guild)
        nextRole = currentRole + 1
        neededXp = 0
        if nextRole >= len(promoArray):
            msg = '┐( ̄ヘ ̄;)┌\nTidak ada role yang lebih tinggi untuk promote *{}*.'.format(DisplayName.name(member))
        else:
            newRole  = DisplayName.roleForID(promoArray[nextRole]['ID'], ctx.guild)
            neededXp = int(promoArray[nextRole]['XP'])-xp
            self.settings.incrementStat(member, ctx.guild, "XP", neededXp)
            # Start at the bottom role and add all roles up to newRole
            addRoles = []
            for i in range(0, nextRole+1):
                addRole  = DisplayName.roleForID(promoArray[i]['ID'], ctx.guild)
                if addRole:
                    if not addRole in member.roles:
                        addRoles.append(addRole)
            # await member.add_roles(*addRoles)
            # Use role manager instead
            self.settings.role.add_roles(member, addRoles)
            if not newRole:
                # Promotion role doesn't exist
                msg = '┐( ̄ヘ ̄;)┌\nSepertinya role **{}** tidak ada dalam server.\n*{}* tetap diberikan sejumlah *{:,} xp*, tapi aku tidak dapat promote ke role yang tidak tercantum dalam list.\nPertimbangkan lagi untuk merevisi role xp.'.format(promoArray[nextRole]['Name'], DisplayName.name(member), neededXp)
            else:
                msg = '*{}* telah memberikan sejumlah *{:,} xp* dan menaikan ke role **{}**!'.format(DisplayName.name(member), neededXp, newRole.name)
            self.bot.dispatch("xp", member, ctx.author, neededXp)
        msgDone = Utils.suppressed(ctx,msg)
        em = discord.Embed(color = 0XFF8C00, description = msgDone)
        em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
        await ctx.send(embed = em)
Beispiel #16
0
 async def _can_run(self, ctx, reply=True):
     # Check if we're admin - and if not, check if bot admins can run this
     # and if we're bot admin
     if Utils.is_admin(ctx): return True
     if self.settings.getServerStat(ctx.guild,"BotAdminAsAdmin",False) and Utils.is_bot_admin_only(ctx): return True
     msg = "┐( ̄ヘ ̄;)┌\nKamu tidak memiliki hak untuk menggunakan command ini."
     em = discord.Embed(color = 0XFF8C00, description = msg)
     em.set_footer(text = "{}".format(ctx.author), icon_url = "{}".format(ctx.author.avatar_url))
     if reply: await ctx.send(embed = em)
     return False
Beispiel #17
0
 async def _can_run(self, ctx, reply=True):
     # Check if we're admin - and if not, check if bot admins can run this
     # and if we're bot admin
     if Utils.is_admin(ctx): return True
     if self.settings.getServerStat(ctx.guild, "BotAdminAsAdmin",
                                    False) and Utils.is_bot_admin_only(ctx):
         return True
     if reply:
         await ctx.send(
             "You do not have sufficient privileges to access this command."
         )
     return False
Beispiel #18
0
    async def mainhw(self, ctx, *, build=None):
        """Sets a new main build from your build list."""

        if not build:
            return await ctx.send(
                "Usage: `{}mainhw [build name or number]`".format(ctx.prefix))

        buildList = self.settings.getGlobalUserStat(ctx.author, "Hardware")
        if buildList == None:
            buildList = []
        buildList = sorted(buildList, key=lambda x: x['Name'].lower())

        mainBuild = None

        # Get build by name first - then by number
        for b in buildList:
            if b['Name'].lower() == build.lower():
                # Found it
                mainBuild = b
                break

        if mainBuild:
            # Found it!
            for b in buildList:
                if b is mainBuild:
                    b['Main'] = True
                else:
                    b['Main'] = False
            self.settings.setGlobalUserStat(ctx.author, "Hardware", buildList)
            msg = "{} set as main!".format(mainBuild['Name'])
            return await ctx.send(Utils.suppressed(ctx, msg))

        try:
            build = int(build) - 1
            if build >= 0 and build < len(buildList):
                mainBuild = buildList[build]
        except:
            pass

        if mainBuild:
            # Found it!
            for b in buildList:
                if b is mainBuild:
                    b['Main'] = True
                else:
                    b['Main'] = False
            self.settings.setGlobalUserStat(ctx.author, "Hardware", buildList)
            msg = "{} set as main!".format(mainBuild['Name'])
            return await ctx.send(Utils.suppressed(ctx, msg))

        msg = "I couldn't find that build or number."
        await ctx.send(msg)
Beispiel #19
0
    async def promote(self, ctx, *, member=None):
        """Auto-adds the required xp to promote the passed user to the next role (admin only)."""
        # Only allow admins to change server stats
        if not await self._can_run(ctx): return
        usage = 'Usage: `{}promote [member]`'.format(ctx.prefix)

        if member == None:
            return await ctx.send(usage)

        memberName = member
        member = DisplayName.memberForName(memberName, ctx.guild)
        if not member:
            msg = 'I couldn\'t find *{}*...'.format(memberName)
            return await ctx.send(Utils.suppressed(ctx, msg))

        # Get user's xp
        xp = int(self.settings.getUserStat(member, ctx.guild, "XP"))

        # Get the role list
        promoArray = self.getSortedRoles(ctx.guild)
        currentRole = self.getCurrentRoleIndex(member, ctx.guild)
        nextRole = currentRole + 1
        neededXp = 0
        if nextRole >= len(promoArray):
            msg = 'There are no higher roles to promote *{}* into.'.format(
                DisplayName.name(member))
        else:
            newRole = DisplayName.roleForID(promoArray[nextRole]['ID'],
                                            ctx.guild)
            neededXp = int(promoArray[nextRole]['XP']) - xp
            self.settings.incrementStat(member, ctx.guild, "XP", neededXp)
            # Start at the bottom role and add all roles up to newRole
            addRoles = []
            for i in range(0, nextRole + 1):
                addRole = DisplayName.roleForID(promoArray[i]['ID'], ctx.guild)
                if addRole:
                    if not addRole in member.roles:
                        addRoles.append(addRole)
            # await member.add_roles(*addRoles)
            # Use role manager instead
            self.settings.role.add_roles(member, addRoles)
            if not newRole:
                # Promotion role doesn't exist
                msg = 'It looks like **{}** is no longer on this server.  *{}* was still given *{:,} xp* - but I am unable to promote them to a non-existent role.  Consider revising your xp roles.'.format(
                    promoArray[nextRole]['Name'], DisplayName.name(member),
                    neededXp)
            else:
                msg = '*{}* was given *{:,} xp* and promoted to **{}**!'.format(
                    DisplayName.name(member), neededXp, newRole.name)
            self.bot.dispatch("xp", member, ctx.author, neededXp)
        await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #20
0
    async def addadmin(self, ctx, *, role: str = None):
        """Adds a new role to the admin list (admin only)."""

        usage = 'Usage: `{}addadmin [role]`'.format(ctx.prefix)

        # Check if we're suppressing @here and @everyone mentions
        if self.settings.getServerStat(ctx.message.guild, "SuppressMentions"):
            suppress = True
        else:
            suppress = False

        if not await Utils.is_admin_reply(ctx): return

        if role == None:
            await ctx.message.channel.send(usage)
            return

        roleName = role
        if type(role) is str:
            if role.lower() == "everyone" or role.lower() == "@everyone":
                role = ctx.guild.default_role
            else:
                role = DisplayName.roleForName(roleName, ctx.guild)
            if not role:
                msg = 'I couldn\'t find *{}*...'.format(roleName)
                msg = Utils.suppressed(ctx, msg)
                await ctx.message.channel.send(msg)
                return

        # Now we see if we already have that role in our list
        promoArray = self.settings.getServerStat(ctx.message.guild,
                                                 "AdminArray")

        for aRole in promoArray:
            # Get the role that corresponds to the id
            if str(aRole['ID']) == str(role.id):
                # We found it - throw an error message and return
                msg = '**{}** is already in the list.'.format(role.name)
                msg = Utils.suppressed(ctx, msg)
                await ctx.message.channel.send(msg)
                return

        # If we made it this far - then we can add it
        promoArray.append({'ID': role.id, 'Name': role.name})
        self.settings.setServerStat(ctx.message.guild, "AdminArray",
                                    promoArray)

        msg = '**{}** added to list.'.format(role.name)
        msg = Utils.suppressed(ctx, msg)
        await ctx.message.channel.send(msg)
        return
Beispiel #21
0
 async def _item_info(self,
                      ctx,
                      name,
                      l_role="RequiredLinkRole",
                      l_list="Links",
                      l_name="Link",
                      l_key="URL"):
     if name == None:
         msg = 'Usage: `{}info{} "[{} name]"`'.format(
             ctx.prefix, l_name.lower(), l_name.lower())
         return await ctx.send(msg)
     itemList = self.settings.getServerStat(ctx.guild, l_list)
     if not itemList or itemList == []:
         msg = 'No [[name]]s in list!  You can add some with the `{}add[[name]] "[[[name]] name]" [[[key]]]` command!'.format(
             ctx.prefix).replace("[[name]]", l_name.lower()).replace(
                 "[[key]]", l_key.lower())
         return await ctx.send(msg)
     safe_name = name.replace("`", "").replace("\\", "")
     item = next((x for x in itemList if x["Name"].lower() == name.lower()),
                 None)
     if not item:
         return await ctx.send(
             Utils.suppressed(
                 ctx, '`{}` not found in {} list!'.format(
                     safe_name, l_name.lower())))
     current_time = int(time.time())
     msg = "**{}:**\n".format(item["Name"])
     # Get the info
     created_by = DisplayName.memberForID(item.get("CreatedID", 0),
                                          ctx.guild)
     created_by = DisplayName.name(created_by) if created_by else item.get(
         "CreatedBy", "`UNKNOWN`")
     msg += "Created by: {}\n".format(created_by)
     created = item.get("Created", None)
     if created:
         msg += "Created: {} ago\n".format(
             ReadableTime.getReadableTimeBetween(created, current_time,
                                                 True))
     if item.get("Updated", None):
         updated_by = DisplayName.memberForID(item.get("UpdatedID", 0),
                                              ctx.guild)
         updated_by = DisplayName.name(
             updated_by) if updated_by else item.get(
                 "UpdatedBy", "`UNKNOWN`")
         msg += "Updated by: {}\n".format(updated_by)
         updated = item.get("Updated", None)
         if created:
             msg += "Updated: {} ago\n".format(
                 ReadableTime.getReadableTimeBetween(
                     updated, current_time, True))
     return await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #22
0
 async def _add_item(self,
                     ctx,
                     name,
                     value,
                     l_role="RequiredLinkRole",
                     l_list="Links",
                     l_name="Link",
                     l_key="URL"):
     # Check if we're admin/bot admin first - then check for a required role
     if not self._has_privs(ctx, l_role):
         return await ctx.send(
             "You do not have sufficient privileges to access this command."
         )
     # Remove tabs, newlines, and carriage returns and strip leading/trailing spaces from the name
     name = None if name == None else name.replace("\n", " ").replace(
         "\r", "").replace("\t", " ").strip()
     # Passed role requirements!
     if name == None or value == None:
         msg = 'Usage: `{}add[[name]] "[[[name]] name]" [[[key]]]`'.format(
             ctx.prefix).replace("[[name]]", l_name.lower()).replace(
                 "[[key]]", l_key.lower())
         return await ctx.send(msg)
     safe_name = name.replace("`", "").replace("\\", "")
     itemList = self.settings.getServerStat(ctx.guild, l_list)
     if not itemList:
         itemList = []
     currentTime = int(time.time())
     item = next((x for x in itemList if x["Name"].lower() == name.lower()),
                 None)
     if item:
         safe_name = item["Name"].replace("`", "").replace("\\", "")
         msg = Utils.suppressed(ctx, '`{}` updated!'.format(safe_name))
         item[l_key] = value
         item['UpdatedBy'] = DisplayName.name(ctx.author)
         item['UpdatedID'] = ctx.author.id
         item['Updated'] = currentTime
     else:
         itemList.append({
             "Name": name,
             l_key: value,
             "CreatedBy": DisplayName.name(ctx.author),
             "CreatedID": ctx.author.id,
             "Created": currentTime
         })
         msg = Utils.suppressed(
             ctx, '`{}` added to {} list!'.format(safe_name,
                                                  l_name.lower()))
     self.settings.setServerStat(ctx.guild, l_list, itemList)
     return await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #23
0
 def _has_privs(self, ctx, l_role="RequiredLinkRole"):
     if not Utils.is_bot_admin(ctx):
         required_role = self.settings.getServerStat(ctx.guild, l_role, "")
         if required_role == "" or not ctx.guild.get_role(
                 int(required_role)) in ctx.author.roles:
             return False
     return True
Beispiel #24
0
 async def _list_items(self,
                       ctx,
                       command,
                       l_role="RequiredLinkRole",
                       l_list="Links",
                       l_name="Link",
                       l_key="URL",
                       raw=False):
     arg_list = ctx.message.content.split()
     if len(arg_list) > 1:
         extra = " ".join(arg_list[1:])
         # We have a random attempt at a passed variable - Thanks Sydney!
         # Invoke this command again with the right name
         return await ctx.invoke(command, name=extra)
     itemList = self.settings.getServerStat(ctx.guild, l_list)
     if not itemList or itemList == []:
         msg = 'No [[name]]s in list!  You can add some with the `{}add[[name]] "[[[name]] name]" [[[key]]]` command!'.format(
             ctx.prefix).replace("[[name]]", l_name.lower()).replace(
                 "[[key]]", l_key.lower())
         return await ctx.send(msg)
     # Sort by link name
     itemList = sorted(itemList, key=lambda x: x['Name'].lower())
     itemText = "**Current {}s:**\n".format(l_name)
     itemText += discord.utils.escape_markdown("\n".join([
         x["Name"] for x in itemList
     ])) if raw else "\n".join([x["Name"] for x in itemList])
     return await Message.Message(message=Utils.suppressed(ctx, itemText)
                                  ).send(ctx)
Beispiel #25
0
    async def ignore(self, ctx, *, member=None):
        """Adds a member to the bot's "ignore" list (bot-admin only)."""
        if not await Utils.is_bot_admin_reply(ctx): return

        if member == None:
            msg = 'Usage: `{}ignore [member]`'.format(ctx.prefix)
            return await ctx.send(msg)

        if type(member) is str:
            memberName = member
            member = DisplayName.memberForName(memberName, ctx.guild)
            if not member:
                msg = 'I couldn\'t find *{}*...'.format(memberName)
                return await ctx.send(Utils.suppressed(ctx, msg))

        ignoreList = self.settings.getServerStat(ctx.guild, "IgnoredUsers")

        for user in ignoreList:
            if str(member.id) == str(user["ID"]):
                # Found our user - already ignored
                return await ctx.send('*{}* is already being ignored.'.format(
                    DisplayName.name(member)))
        # Let's ignore someone
        ignoreList.append({"Name": member.name, "ID": member.id})
        self.settings.setServerStat(ctx.guild, "IgnoredUsers", ignoreList)

        await ctx.send('*{}* is now being ignored.'.format(
            DisplayName.name(member)))
Beispiel #26
0
    async def setuserparts(self,
                           ctx,
                           member: discord.Member = None,
                           *,
                           parts: str = None):
        """Set another user's parts list (owner only)."""
        # Only allow owner
        isOwner = self.settings.isOwner(ctx.author)
        if isOwner == None:
            msg = 'I have not been claimed, *yet*.'
            return await ctx.send(msg)
        elif isOwner == False:
            msg = 'You are not the *true* owner of me.  Only the rightful owner can use this command.'
            return await ctx.send(msg)

        if member == None:
            msg = 'Usage: `{}setuserparts [member] "[parts text]"`'.format(
                ctx.prefix)
            return await ctx.send(msg)

        if type(member) is str:
            try:
                member = discord.utils.get(ctx.guild.members, name=member)
            except:
                return await ctx.send("That member does not exist")

        if not parts:
            parts = ""

        self.settings.setGlobalUserStat(member, "Parts", parts)
        msg = '*{}\'s* parts have been set to:\n{}'.format(
            DisplayName.name(member), parts)
        await ctx.send(Utils.suppressed(ctx, msg))
Beispiel #27
0
    async def listen(self, ctx, *, member=None):
        """Removes a member from the bot's "ignore" list (bot-admin only)."""
        if not await Utils.is_bot_admin_reply(ctx): return

        if member == None:
            return await ctx.send('Usage: `{}listen [member]`'.format(
                ctx.prefix))

        if type(member) is str:
            memberName = member
            member = DisplayName.memberForName(memberName, ctx.guild)
            if not member:
                msg = 'I couldn\'t find *{}*...'.format(memberName)
                return await ctx.send(Utils.suppressed(ctx, msg))

        ignoreList = self.settings.getServerStat(ctx.guild, "IgnoredUsers")

        for user in ignoreList:
            if str(member.id) == str(user["ID"]):
                # Found our user - already ignored
                ignoreList.remove(user)
                self.settings.setServerStat(ctx.guild, "IgnoredUsers",
                                            ignoreList)
                return await ctx.send(
                    "*{}* is no longer being ignored.".format(
                        DisplayName.name(member)))

        await ctx.send('*{}* wasn\'t being ignored...'.format(
            DisplayName.name(member)))
    async def zalgo(self, ctx, *, message=None):
        """Ỉ s̰hͨo̹u̳lͪd͆ r͈͍e͓̬a͓͜lͨ̈l̘̇y̡͟ h͚͆a̵͢v͐͑eͦ̓ i͋̍̕n̵̰ͤs͖̟̟t͔ͤ̉ǎ͓͐ḻ̪ͨl̦͒̂ḙ͕͉d͏̖̏ ṡ̢ͬö̹͗m̬͔̌e̵̤͕ a̸̫͓͗n̹ͥ̓͋t̴͍͊̍i̝̿̾̕v̪̈̈͜i̷̞̋̄r̦̅́͡u͓̎̀̿s̖̜̉͌..."""
        if message == None:
            await ctx.send("Usage: `{}zalgo [message]`".format(ctx.prefix))
            return
        # Check if we're suppressing @here and @everyone mentions
        if self.settings.getServerStat(ctx.message.guild, "SuppressMentions"):
            suppress = True
        else:
            suppress = False

        words = message.split()
        try:
            iterations = int(words[len(words) - 1])
            words = words[:-1]
        except Exception:
            iterations = 1

        if iterations > 100:
            iterations = 100
        if iterations < 1:
            iterations = 1

        zalgo = " ".join(words)
        for i in range(iterations):
            if len(zalgo) > 2000:
                break
            zalgo = self._zalgo(zalgo)

        zalgo = zalgo[:2000]

        # Check for suppress
        zalgo = Utils.suppressed(ctx, zalgo)
        await Message.Message(message=zalgo).send(ctx)
    async def holy(self, ctx, *, subject: str = None):
        """Time to backup the Batman!"""

        if subject == None:
            await ctx.send("Usage: `{}holy [subject]`".format(ctx.prefix))
            return

        # Check if we're suppressing @here and @everyone mentions
        if self.settings.getServerStat(ctx.message.guild, "SuppressMentions"):
            suppress = True
        else:
            suppress = False

        matchList = []
        for a in self.adj:
            if a[:1].lower() == subject[:1].lower():
                matchList.append(a)

        if not len(matchList):
            # Nothing in there - get random entry
            # msg = "*Whoah there!* That was *too* holy for Robin!"
            word = random.choice(self.adj)
            word = word.strip().capitalize()
            subject = subject.strip().capitalize()
            msg = "*Holy {} {}, Batman!*".format(word, subject)
        else:
            # Get a random one
            word = random.choice(matchList)
            word = word.strip().capitalize()
            subject = subject.strip().capitalize()
            msg = "*Holy {} {}, Batman!*".format(word, subject)

        msg = Utils.suppressed(ctx, msg)
        await ctx.send(msg)
Beispiel #30
0
    async def unmorse(self, ctx, *, content=None):
        """Converts morse code to ascii.  Each letter is comprised of "-" or "." and separated by 1 space.  Each word is separated by 4 spaces."""

        if content == None:
            await ctx.send("Usage `{}unmorse [content]`".format(ctx.prefix))
            return

        # Only accept morse symbols
        content = "".join([x for x in content if x in " .-"])
        word_list = content.split("    ")
        ascii_list = []
        for word in word_list:
            # Split by space for letters
            letter_list = word.split()
            letter_ascii = []
            # Iterate through letters
            for letter in letter_list:
                for key in self.to_morse:
                    if self.to_morse[key] == letter:
                        # Found one
                        letter_ascii.append(key.upper())
            if len(letter_ascii):
                # We have letters - join them into ascii words
                ascii_list.append("".join(letter_ascii))

        if not len(ascii_list):
            # We didn't get any valid words
            await ctx.send(
                "There were no valid morse chars in the passed content.")
            return

        # We got *something* - join separated by a space
        msg = " ".join(ascii_list)
        msg = "```\n" + msg + "```"
        await ctx.send(Utils.suppressed(ctx, msg))