<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TwitchLib;
using TwitchLib.Models.Client;
using Discord.WebSocket;
using Discord;
using System.Threading.Tasks;

namespace JefBot.Commands
{
    class CustomCommandsPluginCommand : IPluginCommand
    {
        public string PluginName => "Custom Commands";
        public string Command => "command";
        public string Help => "!cmd add {command name} {command result}";
        public string[] OtherAliases = { "commands", "cmd", "cmds" };
        public IEnumerable<string> Aliases => CustomCommands.Select(command => command.Command).ToArray().Concat(OtherAliases);
        public List<CCommand> CustomCommands = new List<CCommand>();
        public bool Loaded { get; set; } = true;
        private string memoryPath = "./customCommands.txt";

        public CustomCommandsPluginCommand()
        {
            Load();
        }

        async Task<string> IPluginCommand.Action(Message message)
        {
            string res = null;
            await Task.Run(() => { res = CustomCommand(message); });
            if (res != "null")
                return res;
            return res;
        }

        /// <summary>
        /// handles the custom command
        /// </summary>
        /// <param name="command">main command method</param>
        /// <param name="args">arguments</param>
        /// <param name="moderator">if the user is an administrator</param>
        /// <returns></returns>
        private string CustomCommand(Message msg)
        {
            try
            {
                // Main command methods
                if (
                    string.Equals(msg.Command, "command", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "commands", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "cmd", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "cmds", StringComparison.OrdinalIgnoreCase)
                    )
                {
                    if (msg.Arguments.Count > 0)
                    {<commit_msg>fixed bot returning null for commands existing in different channels/servers<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TwitchLib;
using TwitchLib.Models.Client;
using Discord.WebSocket;
using Discord;
using System.Threading.Tasks;

namespace JefBot.Commands
{
    class CustomCommandsPluginCommand : IPluginCommand
    {
        public string PluginName => "Custom Commands";
        public string Command => "command";
        public string Help => "!cmd add {command name} {command result}";
        public string[] OtherAliases = { "commands", "cmd", "cmds" };
        public IEnumerable<string> Aliases => CustomCommands.Select(command => command.Command).ToArray().Concat(OtherAliases);
        public List<CCommand> CustomCommands = new List<CCommand>();
        public bool Loaded { get; set; } = true;
        private string memoryPath = "./customCommands.txt";

        public CustomCommandsPluginCommand()
        {
            Load();
        }

        async Task<string> IPluginCommand.Action(Message message)
        {
            string res = null;
            await Task.Run(() => { res = CustomCommand(message); });
            if (res != "null" && res != null)
                return res;
            else
                return null;
        }

        /// <summary>
        /// handles the custom command
        /// </summary>
        /// <param name="command">main command method</param>
        /// <param name="args">arguments</param>
        /// <param name="moderator">if the user is an administrator</param>
        /// <returns></returns>
        private string CustomCommand(Message msg)
        {
            try
            {
                // Main command methods
                if (
                    string.Equals(msg.Command, "command", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "commands", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "cmd", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(msg.Command, "cmds", StringComparison.OrdinalIgnoreCase)
                    )
                {
                    if (msg.Arguments.Count > 0)
                    {
{'fraction_non_alphanumeric': 0.11288868859846778, 'fraction_numerical': 0.0004506534474988734, 'mean_word_length': 2.015625, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 45, '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': '821453', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1092, 'n_words': 276}