Beispiel #1
0
    async def post(self, bot: openpotd.OpenPOTD, channel: int,
                   potd_role_id: int):
        channel = bot.get_channel(channel)
        if channel is None:
            raise Exception('No such channel!')
        else:
            try:
                identification_name = f'**{self.season_name} - #{self.season_order + 1}**'
                if len(self.images) == 0:
                    await channel.send(
                        f'{identification_name} of {str(date.today())} has no picture attached. '
                    )
                else:
                    await channel.send(
                        f'{identification_name} [{str(date.today())}]',
                        file=discord.File(io.BytesIO(self.images[0]),
                                          filename=f'POTD-{self.id}-0.png'))
                    for i in range(1, len(self.images)):
                        await channel.send(file=discord.File(
                            io.BytesIO(self.images[i]),
                            filename=f'POTD-{self.id}-{i}.png'))

                if potd_role_id is not None:
                    await channel.send(
                        f'DM your answers to me! <@&{potd_role_id}>')
                else:
                    await channel.send(f'DM your answers to me!')
                    logging.warning(
                        f'Config variable ping_role_id is not set! [Server {channel.guild.id}]'
                    )

                # Construct embed and send
                embed = discord.Embed(
                    title=f'{bot.config["otd_prefix"]}oTD {self.id} Stats')
                embed.add_field(name='Difficulty', value=self.difficulty)
                embed.add_field(name='Weighted Solves', value='0')
                embed.add_field(name='Base Points', value='0')
                embed.add_field(name='Solves (official)', value='0')
                embed.add_field(name='Solves (unofficial)', value='0')
                stats_message: discord.Message = await channel.send(embed=embed
                                                                    )
                self.add_stats_message(stats_message.id, channel.guild.id,
                                       stats_message.channel.id)
            except Exception as e:
                self.logger.warning(e)
Beispiel #2
0
def setup(bot: openpotd.OpenPOTD):
    bot.add_cog(Ratings(bot))
Beispiel #3
0
def setup(bot: openpotd.OpenPOTD):
    bot.add_cog(ServerConfig(bot))
Beispiel #4
0
def setup(bot: openpotd.OpenPOTD):
    bot.add_cog(Management(bot))
Beispiel #5
0
def setup(bot: openpotd.OpenPOTD):
    bot.add_cog(Interface(bot))
Beispiel #6
0
def setup(bot: openpotd.OpenPOTD):
    bot.add_cog(MenuManager(bot))