Exemplo n.º 1
0
    async def start_afk(self, convert_from_hc=False):
        self.confirmreactions = self.dungeon_info[2]
        self.rusher_emojis = self.dungeon_info[3]
        self.afk_color = self.dungeon_info[4]
        self.afk_img = self.dungeon_info[5]

        # Setup Reaction
        if self.dungeontitle == "Void" or self.dungeontitle == "Full-Skip Void":
            self.vials = []
        elif self.dungeontitle == "Oryx 3":
            self.swordrunes = []
            self.shieldrunes = []
            self.helmrunes = []

        try:
            await self.setup_msg.delete()
        except discord.NotFound:
            pass
        await self.vcchannel.set_permissions(self.raiderrole,
                                             connect=True,
                                             view_channel=True,
                                             speak=False)

        if not convert_from_hc:
            self.afkmsg = await self.hcchannel.send(
                f"@here `{self.dungeontitle}` {self.emojis[0]} started by {self.ctx.author.mention} "
                f"in {self.vcchannel.name}",
                embed=embeds.afk_check_base(self.dungeontitle, self.ctx.author,
                                            True, self.emojis,
                                            self.confirmreactions,
                                            self.rusher_emojis, self.afk_img,
                                            self.afk_color))
        else:
            await self.hcmsg.clear_reactions()
            await self.hcmsg.edit(
                content=
                f"@here `{self.dungeontitle}` {self.emojis[0]} started by {self.ctx.author.mention} "
                f"in {self.vcchannel.name} (Converted from headcount)",
                embed=embeds.afk_check_base(self.dungeontitle, self.ctx.author,
                                            True, self.emojis,
                                            self.confirmreactions,
                                            self.rusher_emojis, self.afk_img,
                                            self.afk_color))
            pingmsg = await self.hcchannel.send(
                f"@here `{self.dungeontitle}` {self.emojis[0]} re-ping (Headcount -> AFK)"
            )
            try:
                await pingmsg.delete()
            except discord.NotFound:
                pass
            self.afkmsg = self.hcmsg
        await self.afkmsg.pin()

        asyncio.get_event_loop().create_task(self.add_emojis())
        rush = True if self.rusher_emojis else False
        cmojis = True if self.confirmreactions else False
        cp = embeds.afk_check_control_panel(self.afkmsg.jump_url,
                                            self.location,
                                            self.dungeontitle,
                                            self.emojis[1],
                                            True,
                                            rushers=rush,
                                            reactions=cmojis,
                                            vc_name=self.vcchannel.name)
        self.cpmsg = await self.ctx.send(embed=cp)

        await self.cpmsg.add_reaction("📝")
        await self.cpmsg.add_reaction("🗺️")
        await self.cpmsg.add_reaction("🛑")
        await self.cpmsg.add_reaction("❌")

        try:
            pinmsg = await self.hcchannel.fetch_message(
                self.hcchannel.last_message_id)
            if pinmsg.type == discord.MessageType.pins_add:
                await pinmsg.delete()
        except discord.NotFound:
            pass

        self.autoendtask = self.client.loop.create_task(self.wait_for_end())

        self.client.raid_db[self.ctx.guild.id]['afk'][self.afkmsg.id] = self
        self.client.raid_db[self.ctx.guild.id]['cp'][self.cpmsg.id] = self
Exemplo n.º 2
0
    async def start(self):
        self.client.mapmarkers[self.ctx.author.id] = self
        await self.setup_msg.edit(embed=self.worldembed)
        for r in self.numbers:
            await self.setup_msg.add_reaction(r)

        def world_check(reaction, user):
            return user == self.ctx.author and reaction.message.id == self.setup_msg.id and str(reaction.emoji) in self.numbers

        try:
            reaction, user = await self.client.wait_for('reaction_add', timeout=60, check=world_check)
        except asyncio.TimeoutError:
            mapembed = discord.Embed(title="Timed out!", description="You didn't choose a world in time!", color=discord.Color.red())
            await self.setup_msg.clear_reactions()
            return await self.setup_msg.edit(embed=mapembed)

        self.world_num = self.numbers.index(str(reaction.emoji))+1
        self.world_data = self.world_data[f"world_{self.world_num}.png"]

        await self.setup_msg.delete()
        await self.vcchannel.set_permissions(self.raiderrole, connect=True, view_channel=True, speak=False)
        embed = embeds.afk_check_base("Realm Clearing", self.ctx.author, False, self.emojis, [], ["<:planewalker:682212363889279091>"])
        embed.color = discord.Color.gold()
        self.afkmsg = await self.hcchannel.send(f"@here `Realm Clearing` {self.emojis[0]} started by {self.ctx.author.mention} "
                                                f"in {self.vcchannel.name}", embed=embed)

        for emoji in self.emojis:
            await self.afkmsg.add_reaction(emoji)
        await self.afkmsg.add_reaction('<:shard:682365548465487965>')
        await self.afkmsg.add_reaction('❌')

        img_data = await utils.image_upload(open(f"world-maps/world_{self.world_num}.jpg", 'rb'), self.ctx)
        if not img_data:
            return await self.ctx.send("There was an issue communicating with the image server, try again and if the issue "
                                  "persists – contact the developer.", delete_after=10)

        cp = embeds.afk_check_control_panel(self.afkmsg.jump_url, self.location, "Realm Clearing", self.emojis[1], False)
        cp.add_field(name="Markers", value="".join("<@"+str(m)+">" for m in self.markers)+".", inline=True)
        cp.add_field(name="Events Spawned:", value="No events currently spawned", inline=False)
        cp.set_image(url=img_data["secure_url"])
        self.cpmsg = await self.ctx.send("React with :pencil: to toggle map marking for this session",
                                         embed=cp)
        await self.cpmsg.add_reaction("📝")
        mapembed = discord.Embed(title="Current Map:", description="`Spawns left: All -- 0% Cleared`‏‏‎")
        mapembed.set_image(url=img_data["secure_url"])
        mapembed.add_field(name="Events Spawned:", value="No events currently spawned", inline=False)
        self.mapmsg = await self.hcchannel.send(embed=mapembed)

        while True:
            def check(react, usr):
                return not usr.bot and react.message.id == self.afkmsg.id or react.message.id == self.cpmsg.id

            try:
                reaction, user = await self.client.wait_for('reaction_add', timeout=5400, check=check)  # Wait max 1.5 hours
            except asyncio.TimeoutError:
                return await self.end_afk(True)

            if str(reaction.emoji) == self.emojis[0]:
                if user.id not in self.raiderids:
                    self.raiderids.append(user.id)
                    embed = self.afkmsg.embeds[0]
                    embed.set_footer(text=f"Raiders accounted for: {len(self.raiderids)}")
                    await self.afkmsg.edit(embed=embed)
            if str(reaction.emoji) == '<:shard:682365548465487965>':
                if user.premium_since is not None or user.top_role >= self.rlrole:
                    await user.send(f"The location for this realm clearing is: {self.location}")
                    if user.display_name not in self.nitroboosters:
                        self.nitroboosters.append(user.mention)
                    cp = self.cpmsg.embeds[0]
                    cp.set_field_at(1, name="Nitro Boosters", value=str(self.nitroboosters), inline=True)
                    await self.cpmsg.edit(embed=cp)
            elif reaction.emoji == "❌" and user.top_role >= self.rlrole:
                return await self.end_afk(False, user)
            elif reaction.message.id == self.cpmsg.id:
                if user.id in self.markers:
                    if user.id in self.client.mapmarkers:
                        del self.client.mapmarkers[user.id]
                    self.markers.remove(user.id)
                else:
                    self.client.mapmarkers[user.id] = self
                    self.markers.append(user.id)
                cp = self.cpmsg.embeds[0]
                cp.set_field_at(3, name="Markers", value="".join("<@"+str(m)+">" for m in self.markers)+".", inline=True)
                await self.cpmsg.edit(embed=cp)
Exemplo n.º 3
0
    async def start(self):
        await self.setup_msg.edit(embed=self.worldembed)
        for r in self.numbers:
            await self.setup_msg.add_reaction(r)

        def world_check(reaction, user):
            return user == self.ctx.author and reaction.message.id == self.setup_msg.id and str(
                reaction.emoji) in self.numbers

        try:
            reaction, user = await self.client.wait_for('reaction_add',
                                                        timeout=60,
                                                        check=world_check)
        except asyncio.TimeoutError:
            mapembed = discord.Embed(
                title="Timed out!",
                description="You didn't choose a world in time!",
                color=discord.Color.red())
            await self.setup_msg.clear_reactions()
            return await self.setup_msg.edit(embed=mapembed)

        index = self.numbers.index(str(reaction.emoji))
        self.world_num = 1 if index == 0 else 3 if index == 1 else 10 if index == 2 else 12

        await self.setup_msg.delete()
        if " <-- Join!" not in self.vcchannel.name:
            await self.vcchannel.edit(name=self.vcchannel.name + " <-- Join!")
        await self.vcchannel.set_permissions(self.raiderrole,
                                             connect=True,
                                             view_channel=True,
                                             speak=False)

        self.afkmsg = await self.hcchannel.send(
            f"@here `Fame Train` {self.emojis[0]} started by {self.ctx.author.mention} "
            f"in {self.vcchannel.name}",
            embed=embeds.fame_train_afk(self.ctx.author, self.vcchannel,
                                        self.world_num))
        for emoji in self.emojis:
            await self.afkmsg.add_reaction(emoji)
        await self.afkmsg.add_reaction('<:shard:682365548465487965>')
        await self.afkmsg.add_reaction('❌')

        cp = embeds.afk_check_control_panel(self.afkmsg.jump_url,
                                            self.location, "Fame Train",
                                            self.emojis[1], False)
        self.cpmsg = await self.ctx.send(embed=cp)

        while True:

            def check(react, usr):
                return not usr.bot and react.message.id == self.afkmsg.id

            try:
                reaction, user = await self.client.wait_for(
                    'reaction_add', timeout=14400,
                    check=check)  # Wait max 1.5 hours
            except asyncio.TimeoutError:
                return await self.end_afk(True)

            if str(reaction.emoji) == self.emojis[0]:
                if user.id not in self.raiderids:
                    self.raiderids.append(user.id)
                    embed = self.afkmsg.embeds[0]
                    embed.set_footer(
                        text=f"Raiders accounted for: {len(self.raiderids)}")
                    await self.afkmsg.edit(embed=embed)
            elif str(reaction.emoji) == '<:shard:682365548465487965>':
                if user.premium_since is not None or user.top_role >= self.rlrole:
                    await user.send(
                        f"The location for this fame train is: {self.location}"
                    )
                    if user.display_name not in self.nitroboosters:
                        self.nitroboosters.append(user.mention)
                    cp = self.cpmsg.embeds[0]
                    cp.set_field_at(1,
                                    name="Nitro Boosters",
                                    value=str(self.nitroboosters),
                                    inline=True)
                    await self.cpmsg.edit(embed=cp)
            elif reaction.emoji == "❌" and user.top_role >= self.rlrole:
                return await self.end_afk(False, user)