public async Task RemoveGame(string word1) { var roleName = word1; var user = Context.Guild.GetUser(Context.User.Id); var role = user.Guild.Roles.Where(has => has.Name.ToUpper() == roleName.ToUpper()); string GameNames = ""; for (int i = 0; i < Datastorage.GetPairsCount(); i++) { string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}"); GameNames += GameName + "\n"; } if (GameNames.Contains(roleName.ToUpper())) { await user.RemoveRolesAsync(role); await Context.Channel.SendMessageAsync($"Game: {roleName} removed from your account :thumbsup:"); Console.WriteLine(String.Format("{0:G}") + $"Role: {roleName.ToUpper()} removed from {user} || Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}"); } else { await Context.Channel.SendMessageAsync($" :no_entry: Game: {roleName} doesn't exist. Use `?gamehelp` for the list of games :no_entry:"); } }
public async Task GameRole1(string word1) { string GameNames = ""; var user = Context.Guild.GetUser(Context.User.Id); var roleName = word1; var role = user.Guild.Roles.Where(has => has.Name.ToUpper() == roleName.ToUpper()); var test = Context.Guild.Roles.ToArray(); for (int i = 0; i < Datastorage.GetPairsCount(); i++) { string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}"); GameNames += GameName + "\n"; } if (GameNames.Contains(roleName.ToUpper())) { await user.AddRolesAsync(role); await Context.Channel.SendMessageAsync($"Game: {roleName} added to your account :thumbsup: "); Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $"Role: {roleName.ToUpper()} added to {user} || Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}"); } else { await Context.Channel.SendMessageAsync($" :no_entry: Game: {roleName} is not added yet use `?gamehelp` for the list of games :no_entry:"); } }
public async Task AddGameRole(string RoleName) { var GuildUser = await((IGuild)Context.Guild).GetUserAsync(Context.User.Id); if (admins.Contains(GuildUser.Id)) { var user = Context.Guild.GetUser(Context.User.Id); var embed = new EmbedBuilder(); rnd = new Random(); embed.WithDescription($"Game: `{RoleName}` added"); embed.WithColor(new Color(rnd.Next(255), rnd.Next(255), rnd.Next(255))); await Context.Guild.CreateRoleAsync(RoleName.Replace("|", " "), null, Color.Default, false, null); await Context.Channel.SendMessageAsync("", false, embed); //Adding game to data Datastorage.AddPairToStorage("Role" + Datastorage.GetPairsCount() + Context.Guild.Id, RoleName.ToUpper()); } else { //error message await Context.Channel.SendMessageAsync(":no_entry: You shall not use this command :no_entry: "); Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $" Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User} tried to use ?AddGame "); } }
public async Task GameRoleHelp() { var embed = new EmbedBuilder(); string GameNames = ""; rnd = new Random(); string HelpMsg1 = Utilities.GetFormattedAlert("GameRoleHelp1"); string HelpMsg2 = Utilities.GetFormattedAlert("GameRoleHelp2"); string HelpMsg3 = Utilities.GetFormattedAlert("GameRoleHelp3"); string RemoveGame = Utilities.GetFormattedAlert("RemoveGame"); embed.WithTitle($"Info for {Context.User.Username}"); embed.WithDescription(HelpMsg1 + HelpMsg2); embed.WithThumbnailUrl("https://i.gyazo.com/f29f36719c4aa76076aa8d764d35b96d.jpg"); embed.WithColor(new Color(rnd.Next(255), rnd.Next(255), rnd.Next(255))); embed.WithCurrentTimestamp(); for (int i = 0; i < Datastorage.GetPairsCount(); i++) { string GameName = Datastorage.GetFormattedAlert($"Role{i}{Context.Guild.Id}"); GameNames += GameName + "\n"; } embed.AddField("Available games:", GameNames); embed.AddField("My game is not in the list.", HelpMsg3); embed.AddField("How do i remove a game that i added?", RemoveGame); await Context.Channel.SendMessageAsync("", false, embed); Console.WriteLine(String.Format("{0:G}", DateTime.Now) + $"Server: {Context.Guild} || Channel: {Context.Channel} || User: {Context.User}"); }
static UserAccounts() { if (Datastorage.FileExists(AccountFolder + "/" + AccountFile)) { accounts = Datastorage.GetUserAccounts(AccountFolder, AccountFile).ToList(); } else { accounts = new List <UserAccount>(); SaveAccount(); } }
static UserAccounts() { if (Datastorage.SaveExists(accountsfile)) { accounts = Datastorage.LoadUserAccounts(accountsfile).ToList(); } else { accounts = new List <UserAccount>(); SaveAccounts(); } }
public void attachEventListenerObjects(JsonConfig Config, bool as_docker) { LogFormater.Info("HTTP service requested:" + Config.Http_Enable.ToString()); if (Config.Http_Enable == true) { new Thread(() => { new HttpAsService(Bot, Config, as_docker); }).Start(); } Adverts = new advertsService(this, as_docker); Events = new onevent(this, as_docker); betterAtHomeService = new BetterAtHome(this, Config); betterTracking = new BetterTracking(this); datastorage = new Datastorage(this); }
public static UserAccount GetAccount(SocketUser user, SocketGuild guild) { var accountsFile = $"Data/UserData/{guild.Id}/{user.Id}.json"; if (Datastorage.SaveExists(accountsFile)) { Accounts = Datastorage.LoadUserAccounts(accountsFile).ToList(); } else { Directory.CreateDirectory($"Data/UserData/{guild.Id}"); Accounts = new List <UserAccount>(); SaveAccounts(user, guild); } return(GetOrCreateAccount(user.Id)); }
public async Task allUsers() { UserAccount.UserAccount useraccount = new UserAccount.UserAccount(); var GuildUser = await((IGuild)Context.Guild).GetUserAsync(Context.User.Id); if (admins.Contains(GuildUser.Id)) { Console.WriteLine(Datastorage.LoadUserAccounts("Data/UserData/accounts.json")); foreach (object User in useraccount.ToString()) { var Id = useraccount.ID; var Level = useraccount.Level; var TimeConnected = useraccount.TimeConnected; Console.WriteLine($"{Id}, {Level}, {TimeConnected}"); } } }
protected void keep_alive() { while (Bot.KillMe == false) { string NewStatusMessage = Bot.GetStatus(); NewStatusMessage = NewStatusMessage.Trim(); if (NewStatusMessage != Bot.LastStatusMessage) { if (NewStatusMessage.Replace(" ", "") != "") { Bot.LastStatusMessage = NewStatusMessage; Bot.Log2File(LogFormater.Status(Bot.LastStatusMessage, false), ConsoleLogLogLevel.Status); } } Thread.Sleep(1500); } Adverts = null; Events = null; betterAtHomeService = null; betterTracking = null; datastorage = null; Bot = null; exitBot = true; }
public static void SaveAccount() { Datastorage.SaveUserAccounts(accounts, AccountFolder, AccountFile); }
public static void SaveAccounts() { Datastorage.SaveUserAccounts(accounts, accountsfile); }
public async Task Profanity(string word) { Utilities.profanity.Add(word); Datastorage.saveProfanityData(Utilities.profanity); }
public async Task Data() { await Context.Channel.SendMessageAsync("Data has " + Datastorage.GetPairsCount() + " pairs"); //Datastorage.AddPairToStorage("TEST", "Dette er en test"); }
public static void SaveAccounts(SocketUser user, SocketGuild guild) { var accountsFile = $"Data/UserData/{guild.Id}/{user.Id}.json"; Datastorage.SaveUserAccounts(Accounts, accountsFile); }