<commit_before><?php

namespace Bot\Commands\Overwatch;

use Bot\Commands\BaseCommand;
use Bot\Database;

class Top extends BaseCommand
{
    public $keywords = '!top';
    public $help = 'Affiche le classement compétitif des joueurs';

    public function execute()
    {
        $players = Database::select();

        if (count($players) === 0) {
            $this->send("Aucun joueur enregistré");
            return;
        }

        usort($players, function ($a, $b) {
            return $a->rank < $b->rank;
        });

        $output = '';
        $output .= 'Classement compétitif des joueurs :' . PHP_EOL;
        $output .= '```' . PHP_EOL;
        $output .= ' #  Battletag               Rank' . PHP_EOL;
        $output .= '——————————————————————————————————' . PHP_EOL;

        foreach ($players as $key => $player) {
            $tag = explode('#', $player->battletag)[0];

            if (! empty($player->discord)) {
                $user = $this->message->channel->guild->members->get("id", $player->discord);
                $nick = $user->nick; // Mandatory assignation to resolve the data
                $name = ! empty($nick) ? $nick : $user->username;
                if ($name !== $tag) {
                    $tag .= ' (' . $name . ')';
                }
            }
            $output .= str_pad($key + 1, 2, ' ', STR_PAD_LEFT) . '  ';
            $output .= str_pad($tag, 24 + (strlen($tag) - mb_strlen($tag)));
            $output .= $player->rank . PHP_EOL;
        }
        $output .= "```";
        $this->send($output);
    }
}
<commit_msg>Fixed Discord name not displayed when connected on multiple guilds<commit_after><?php

namespace Bot\Commands\Overwatch;

use Bot\Commands\BaseCommand;
use Bot\Database;

class Top extends BaseCommand
{
    public $keywords = '!top';
    public $help = 'Affiche le classement compétitif des joueurs';

    public function execute()
    {
        $players = Database::select();

        if (count($players) === 0) {
            $this->send("Aucun joueur enregistré");
            return;
        }

        usort($players, function ($a, $b) {
            return $a->rank < $b->rank;
        });

        $output = '';
        $output .= 'Classement compétitif des joueurs :' . PHP_EOL;
        $output .= '```' . PHP_EOL;
        $output .= ' #  Battletag               Rank' . PHP_EOL;
        $output .= '——————————————————————————————————' . PHP_EOL;

        foreach ($players as $key => $player) {
            $tag = explode('#', $player->battletag)[0];

            if (! empty($player->discord)) {
                $user = $this->message->channel->guild->members->get("id", $player->discord);
                $nick = $user->nick; // Mandatory assignation to resolve the data
                $name = ! empty($nick) ? $nick : $user->username;
                if ($name !== $tag && ! empty($name)) {
                    $tag .= ' (' . $name . ')';
                }
            }
            $output .= str_pad($key + 1, 2, ' ', STR_PAD_LEFT) . '  ';
            $output .= str_pad($tag, 24 + (strlen($tag) - mb_strlen($tag)));
            $output .= $player->rank . PHP_EOL;
        }
        $output .= "```";
        $this->send($output);
    }
}

{'fraction_non_alphanumeric': 0.1899164862356944, 'fraction_numerical': 0.0037117228580266005, 'mean_word_length': 1.8, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2205835', 'n_tokens_mistral': 1020, 'n_tokens_neox': 982, 'n_words': 214}