示例#1
0
    def stars_block(self, event, user):
        _, created = StarboardBlock.get_or_create(guild_id=event.guild.id,
                                                  user_id=user.id,
                                                  defaults={
                                                      'actor_id':
                                                      event.author.id,
                                                  })

        if not created:
            event.msg.reply(u'{} is already blocked from the starboard'.format(
                user, ))
            return

        # Update the starboard, remove stars and posts
        StarboardEntry.block_user(user.id)

        # Finally, queue an update for the guild
        self.queue_update(event.guild.id, event.config)

        event.msg.reply(u'Blocked {} from the starboard'.format(user, ))
示例#2
0
    def stars_block(self, event, entity):
        _, created = StarboardBlock.get_or_create(guild_id=event.guild.id,
                                                  user_id=entity.id,
                                                  defaults={
                                                      'actor_id':
                                                      event.author.id,
                                                  })

        if not created:
            raise CommandFail(
                '{} is already not allowed on the starboard'.format(entity, ))

        # Update the starboard, remove stars and posts
        StarboardEntry.block(entity.id)

        # Finally, queue an update for the guild
        self.queue_update(event.guild.id, event.config)

        raise CommandSuccess('Disallowed {} from the starboard'.format(
            entity, ))