<commit_before>require 'discordrb'
require 'fullwidth'
require 'yaml'
require 'figlet'
require 'cowsay'
require 'fortune_gem'
require_relative 'lib/utilities'
require_relative 'lib/fun'
require_relative 'lib/info'

$config = YAML.load_file('config.yaml')
$infofile = 'info.yaml'
$pasta = YAML.load_file('pasta.yaml')

#Figlet initialization
$font = Figlet::Font.new("fonts/#{$config['figletFont']}.flf")
$figlet = Figlet::Typesetter.new($font)

$bot = Discordrb::Commands::CommandBot.new(token: $config['token'],
                                           prefix: $config['prefix'],
                                           advanced_functionality: true,
                                           spaces_allowed: true,
                                           chain_delimiter: '|',
                                           previous: '-',
                                           ignore_bots: true)

$bot.include! Utilities
$bot.include! Fun
$bot.include! Info

$userType = 'normal'

$bot.command :sudo do |event, *args|
  if event.author.roles.include?($config['sudoersRole'])
    runCommand = args[0]
    args.slice!(0)
    $userType = 'sudoer'
    $bot.execute_command(runCommand.to_sym, event, args)
  else
    event.channel.send_message("<@#{event.author.id.to_s}> is not in the sudoers file. This incident will be reported.")
    $bot.send_message($config['sudoLogChannel'], "<@#{event.author.id.to_s}> is getting coal for Christmas.")
  end
end

$pasta.keys.each do |pasta| # Slightly improved
  $bot.command pasta.to_sym do |event, *args|

    sed = []
    args.each { |string| string.split('/').each { |subs| sed.push(subs)}}
    event.channel.send_embed do |embed|
      embed_raw = $pasta[pasta]['embed']
      unless sed.empty?
        sed.each_slice(2) do |match, replace|
          embed_raw['description'].gsub!(/#{match}/i, replace)
        end
        embed.description = embed_raw['description']
      end

      if embed_raw['author']
        embed_raw = embed_raw['author']
        embed.author = Discordrb::Webhooks::EmbedAuthor.new(
                name: embed_raw['name'],
                url: embed_raw['url'],
                icon_url: embed_raw['icon_url'] )
      end
    end
  end
end

$bot.run<commit_msg>Fixed a behaviour with empty args<commit_after>require 'discordrb'
require 'fullwidth'
require 'yaml'
require 'figlet'
require 'cowsay'
require 'fortune_gem'
require_relative 'lib/utilities'
require_relative 'lib/fun'
require_relative 'lib/info'

$config = YAML.load_file('config.yaml')
$infofile = 'info.yaml'
$pasta = YAML.load_file('pasta.yaml')

#Figlet initialization
$font = Figlet::Font.new("fonts/#{$config['figletFont']}.flf")
$figlet = Figlet::Typesetter.new($font)

$bot = Discordrb::Commands::CommandBot.new(token: $config['token'],
                                           prefix: $config['prefix'],
                                           advanced_functionality: true,
                                           spaces_allowed: true,
                                           chain_delimiter: '|',
                                           previous: '-',
                                           ignore_bots: true)

$bot.include! Utilities
$bot.include! Fun
$bot.include! Info

$userType = 'normal'

$bot.command :sudo do |event, *args|
  if event.author.roles.include?($config['sudoersRole'])
    runCommand = args[0]
    args.slice!(0)
    $userType = 'sudoer'
    $bot.execute_command(runCommand.to_sym, event, args)
  else
    event.channel.send_message("<@#{event.author.id.to_s}> is not in the sudoers file. This incident will be reported.")
    $bot.send_message($config['sudoLogChannel'], "<@#{event.author.id.to_s}> is getting coal for Christmas.")
  end
end

$pasta.keys.each do |pasta| # Slightly improved
  $bot.command pasta.to_sym do |event, *args|

    sed = []
    args.each { |string| string.split('/').each { |subs| sed.push(subs)}}
    event.channel.send_embed do |embed|
      embed_raw = $pasta[pasta]['embed']
      embed.description = embed_raw['description']
      unless sed.empty?
        sed.each_slice(2) do |match, replace|
          embed.description.gsub!(/#{match}/i, replace)
        end
      end

      if embed_raw['author']
        embed_raw = embed_raw['author']
        embed.author = Discordrb::Webhooks::EmbedAuthor.new(
                name: embed_raw['name'],
                url: embed_raw['url'],
                icon_url: embed_raw['icon_url'] )
      end
    end
  end
end

$bot.run
{'fraction_non_alphanumeric': 0.13776986423325172, 'fraction_numerical': 0.0013354106387714222, 'mean_word_length': 2.391698113207547, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284612', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1349, 'n_words': 280}