Example #1
0
File: Bot.cs Project: 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);
        }
Example #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]);
                };
            }
        }
Example #3
0
File: Bot.cs Project: amishshah/IA
 public Bot(Action <ClientInformation> info)
 {
     clientInformation = new ClientInformation();
     info.Invoke(clientInformation);
     InitializeBot().GetAwaiter().GetResult();
 }
Example #4
0
File: Bot.cs Project: amishshah/IA
 public Bot(ClientInformation info)
 {
     clientInformation = info;
     InitializeBot().GetAwaiter().GetResult();
 }
Example #5
0
 public static void InitializeLogging(ClientInformation c)
 {
     client = c;
 }