Esempio n. 1
0
File: Bot.cs Progetto: amishshah/IA
        private ClientInformation InitializePreferencesFile()
        {
            ClientInformation outputBotInfo = new ClientInformation();
            FileWriter        file          = new FileWriter("preferences", "config");

            file.WriteComment(VersionText + " preferences file");
            file.WriteComment("Please do not change this file except to change\n# except to change your settings");
            file.WriteComment("Bot Name");
            Console.WriteLine("Enter bot name: ");
            string inputString = Console.ReadLine();

            file.Write(inputString);
            outputBotInfo.Name = inputString;

            file.WriteComment("Bot Token");
            Console.WriteLine("Enter bot token: ");
            inputString = Console.ReadLine();
            file.Write(inputString);
            outputBotInfo.Token = inputString;

            file.WriteComment("Shard count");
            Console.WriteLine("Shards [1-25565]:");
            inputString = Console.ReadLine();
            outputBotInfo.ShardCount = int.Parse(inputString);
            if (outputBotInfo.ShardCount < 1)
            {
                outputBotInfo.ShardCount = 1;
            }
            else if (outputBotInfo.ShardCount > 25565)
            {
                outputBotInfo.ShardCount = 25565;
            }

            file.Finish();

            return(outputBotInfo);
        }
Esempio n. 2
0
        public ShardedClient(ClientInformation clientInfo)
        {
            Log.Message(clientInfo.ShardCount.ToString());

            info = clientInfo;

            for (int i = 0; i < info.ShardCount; i++)
            {
                shards.Add(new DiscordSocketClient(new DiscordSocketConfig()
                {
                    ShardId     = i,
                    TotalShards = info.ShardCount
                }));

                shards[i].MessageReceived += async(message) =>
                {
                    await OnMessageRecieved(shards[i], message);
                };
                shards[i].Ready += async() =>
                {
                    await OnReady(shards[i]);
                };
            }
        }
Esempio n. 3
0
File: Bot.cs Progetto: amishshah/IA
 public Bot(Action <ClientInformation> info)
 {
     clientInformation = new ClientInformation();
     info.Invoke(clientInformation);
     InitializeBot().GetAwaiter().GetResult();
 }
Esempio n. 4
0
File: Bot.cs Progetto: amishshah/IA
 public Bot(ClientInformation info)
 {
     clientInformation = info;
     InitializeBot().GetAwaiter().GetResult();
 }
Esempio n. 5
0
 public static void InitializeLogging(ClientInformation c)
 {
     client = c;
 }