<commit_before>module SerieBot
  module Utility
    extend Discordrb::Commands::CommandContainer

    command(:avatar, description: 'Displays the avatar of a user.') do |event, *mention|
      event.channel.start_typing # Let people know the bot is working on something.
        if mention.nil?
          user = event.message.author
        elsif event.message.mentions[0]
          user = event.server.member(event.message.mentions[0])
        else
          event << '❌ Mention a valid user!'
          next
        end
        avatar_path = Helper.download_avatar(user, 'tmp')
        event.channel.send_file File.new([avatar_path].sample)
    end

    command(:ping) do |event|
      return_message = event.respond('Ping!')
      ping = (return_message.id - event.message.id) >> 22
      return_message.edit("Pong! - #{ping}ms")
    end

    command(:info, description: 'Displays info about a user.') do |event, *mention|
      event.channel.start_typing
      if event.channel.private? # ignore PMs
        event << '❌ This command can only be used in a server.'
        next
      end

      if event.message.mentions[0]
        user = event.message.mentions[0]
        if user.game.nil?
          playing = '[N/A]'
        else
          playing = user.game
        end
        member = user.on(event.server)
        if member.nickname.nil?
          nick = '[N/A]' #
        else
          nick = member.nickname
        end
        event << "👥  Information about **#{member.display_name}**"
        event << "-ID: **#{user.id}**"
        event << "-Username: `#{user.distinct}`"
        event << "-Nickname: **#{nick}**"
        event << "-Status: **#{user.status}**"
        event << "-Playing: **#{playing}**"
        event << "-Account created: **#{user.creation_time.getutc.asctime}** UTC"
        event << "-Joined server at: **#{member.joined_at.getutc.asctime}** UTC"
      end
    end

    command(:ping) do |event|
      return_message = event.respond('Ping!')
      ping = (return_message.id - event.message.id) >> 22
      return_message.edit("Pong! - #{ping}ms")
    end

    # Requires manage_roles permission since that's what we're doing.
    command(:config, description: 'Change settings per-server for the bot.', required_permissions: [:manage_roles]) do |event, option, *args|
      # TODO: more configuration options?
      if option == 'help'
        help = "__Help for #{Config.prefix}config:__\n\n"
        help += "_setrole_: Set the role to be used in place of Developers and Moderators. See #{Config.prefix}help for information about what these roles provide.\n"
        help += "_setchannel_: Sets the channel to be used for specific logging items, such as server logs.\n"
        event.respond(help)
      elsif option == 'setrole'
        # Make sure that there are 2+ options here, so we don't waste our time.
        if args.length < 2
          event.respond('❌ Make sure to follow the syntax correctly!')
          break
        end

        role_type = args[0]
        valid_role_types = %w(dev bot mod)

        # Make sure that the short ID is valid
        unless valid_role_types.include? role_type
          response = '❌ Make sure to type in a valid role type!' + "\n"
          response += 'Valid types are:' + "\n"
          valid_role_types.each do |type|<commit_msg>Add additional types<commit_after>module SerieBot
  module Utility
    extend Discordrb::Commands::CommandContainer

    command(:avatar, description: 'Displays the avatar of a user.') do |event, *mention|
      event.channel.start_typing # Let people know the bot is working on something.
        if mention.nil?
          user = event.message.author
        elsif event.message.mentions[0]
          user = event.server.member(event.message.mentions[0])
        else
          event << '❌ Mention a valid user!'
          next
        end
        avatar_path = Helper.download_avatar(user, 'tmp')
        event.channel.send_file File.new([avatar_path].sample)
    end

    command(:ping) do |event|
      return_message = event.respond('Ping!')
      ping = (return_message.id - event.message.id) >> 22
      return_message.edit("Pong! - #{ping}ms")
    end

    command(:info, description: 'Displays info about a user.') do |event, *mention|
      event.channel.start_typing
      if event.channel.private? # ignore PMs
        event << '❌ This command can only be used in a server.'
        next
      end

      if event.message.mentions[0]
        user = event.message.mentions[0]
        if user.game.nil?
          playing = '[N/A]'
        else
          playing = user.game
        end
        member = user.on(event.server)
        if member.nickname.nil?
          nick = '[N/A]' #
        else
          nick = member.nickname
        end
        event << "👥  Information about **#{member.display_name}**"
        event << "-ID: **#{user.id}**"
        event << "-Username: `#{user.distinct}`"
        event << "-Nickname: **#{nick}**"
        event << "-Status: **#{user.status}**"
        event << "-Playing: **#{playing}**"
        event << "-Account created: **#{user.creation_time.getutc.asctime}** UTC"
        event << "-Joined server at: **#{member.joined_at.getutc.asctime}** UTC"
      end
    end

    command(:ping) do |event|
      return_message = event.respond('Ping!')
      ping = (return_message.id - event.message.id) >> 22
      return_message.edit("Pong! - #{ping}ms")
    end

    # Requires manage_roles permission since that's what we're doing.
    command(:config, description: 'Change settings per-server for the bot.', required_permissions: [:manage_roles]) do |event, option, *args|
      # TODO: more configuration options?
      if option == 'help'
        help = "__Help for #{Config.prefix}config:__\n\n"
        help += "_setrole_: Set the role to be used in place of Developers and Moderators. See #{Config.prefix}help for information about what these roles provide.\n"
        help += "_setchannel_: Sets the channel to be used for specific logging items, such as server logs.\n"
        event.respond(help)
      elsif option == 'setrole'
        # Make sure that there are 2+ options here, so we don't waste our time.
        if args.length < 2
          event.respond('❌ Make sure to follow the syntax correctly!')
          break
        end

        role_type = args[0]
        valid_role_types = %w(dev bot mod hlp vfd)

        # Make sure that the short ID is valid
        unless valid_role_types.include? role_type
          response = '❌ Make sure to type in a valid role type!' + "\n"
          response += 'Valid types are:' + "\n"
          valid_role_types.each do |type|
{'fraction_non_alphanumeric': 0.12265143544265744, 'fraction_numerical': 0.0033067788967383136, 'mean_word_length': 2.358909641595154, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '67155', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1977, 'n_words': 597}