Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using Discord;
- namespace SelfBot
- {
- class Program
- {
- public DiscordClient _client;
- static void Main(string[] args)
- {
- Console.Title = "Initializing...";
- Console.InputEncoding = Console.OutputEncoding = Encoding.Unicode;
- Program bot = new Program();
- try
- {
- UserInfo user = LoadUser(args[0]);
- bot.LogIn(user);
- }
- catch (Exception e)
- {
- Console.WriteLine($"[EXCEPTION]: {e.Message}\n\nProgram will now TRY to safely exit. Press any key to continue.)");
- }
- Console.ReadKey();
- }
- private void LogIn(UserInfo user)
- {
- _client = new DiscordClient(x =>
- {
- x.AppName = "Purple Ice's Bot";
- x.LogLevel = LogSeverity.Error;
- x.LogHandler = Log;
- });
- _client.MessageReceived += (async (s, e) =>
- {
- if (e.Message.IsAuthor)
- {
- _client.SetGame($"[{DateTime.Now.Hour,0:D2}:{DateTime.Now.Minute,0:D2}]");
- }
- if (e.Message.User.Id == 194152334312472577 && e.Channel.IsPrivate)
- {
- await e.Channel.SendMessage("I love you <3"); // hehe xd
- }
- });
- _client.ExecuteAndWait(async () =>
- {
- Console.Title = "Connecting...";
- await _client.Connect(user.email, user.password);
- Console.Title = $"{_client.CurrentUser.Name}";
- Console.WriteLine("Thanks <3\n\n\nI mean, it works.");
- });
- }
- private void Log(object sender, LogMessageEventArgs e)
- {
- Console.WriteLine($"[{e.Severity}] [{e.Source}] [{e.Message}]");
- }
- private static UserInfo LoadUser(string path)
- {
- if (Path.GetExtension(path) != ".sbu")
- {
- throw new Exception("This program supports only .sbu files.");
- }
- string[] lines = File.ReadAllLines(path, Encoding.UTF8);
- return new UserInfo(lines[0], lines[1]);
- }
- }
- struct UserInfo
- {
- public string email { get; private set; }
- public string password { get; private set; }
- public UserInfo(string email, string password)
- {
- this.email = email;
- this.password = password;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement