//When a user leaves, say goodbye. public static async Task UserLeftAsync(SocketGuildUser e) { var server = Tools.GetServerInfo(e.Guild.Id); if (server.welcomingChannel == 0) return; await Tools.ReplyAsync(e, Storage.client.GetChannel(server.welcomingChannel) as ITextChannel, $"Goodbye, **{e.Mention}**. It was nice having you here. ({e.Username})", false); }
//When a user joins the server it welcomes the user. public static async Task UserJoinedAsync(SocketGuildUser e) { await Modules.Information.WelcomeUserAsync(Storage.client, e, e.Guild.Id); }
public static async Task SetFirstThemeConfirm(SocketGuildUser user, RestUserMessage message) { // Get the account information of the command's target var account = UserInfoClasses.GetAccount(user); // Find the menu session associated with the current user. var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id); // Create a new embed that will be displayed in the message. var embed = new EmbedBuilder(); var author = new EmbedAuthorBuilder { Name = "Settings Saved", IconUrl = user.GetAvatarUrl() }; embed.WithAuthor(author); string game_title = ""; embed.WithColor(EmbedSettings.Get_Profile_Embed_Color(account)); // Determine the color and thumbnail for the embeded message. if (account.Profile_Theme == "P3") { game_title = "Persona 3"; embed.WithThumbnailUrl("https://i.imgur.com/trtPflx.png"); } else if (account.Profile_Theme == "P4") { game_title = "Persona 4"; embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P4-PS2")); } else if (account.Profile_Theme == "P5") { game_title = "Persona 5"; embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P5-PS4")); } embed.WithDescription($"" + $"Your profile theme has been set to `{game_title}`.\n\n" + $"You can change your profile theme at any time from the **`{BotConfig.bot.cmdPrefix}settings`** menu by choosing [Profile Theme Settings]."); var footer = new EmbedFooterBuilder { Text = "❌ Close Menu" }; // Add the footer to the embed. embed.WithFooter(footer); // Attempt editing the message if it hasn't been deleted by the user yet. If it has, catch the exception, send an error message, and return. try { // Remove all reactions from the current message. await message.RemoveAllReactionsAsync(); // Edit the current active message by replacing it with the recently created embed. await message.ModifyAsync(x => { x.Embed = embed.Build(); }); } catch (Exception ex) { await ErrorHandling.MissingMessageError((SocketTextChannel)message.Channel); Console.WriteLine(ex); return; } // Edit the menu session according to the current message. menuSession.CurrentMenu = "Set_First_Theme_Confirm"; menuSession.MenuTimer = new Timer() { // Create a timer that expires as a "time out" duration for the user. Interval = MenuConfig.menu.timerDuration, AutoReset = false, Enabled = true }; // If the menu timer runs out, activate a function. menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession); // Create an empty list for reactions. List <IEmote> reaction_list = new List <IEmote> { }; // Add needed emote reactions for the menu. reaction_list.Add(new Emoji("❌")); // Add the reactions to the message. _ = ReactionHandling.AddReactionsToMenu(message, reaction_list); }
private async Task ChangeName(SocketGuildUser user, string name) { string oldNick = user.Nickname; await user.ModifyAsync(u => u.Nickname = name); }
public async Task BeleidigungAsync([Summary("The insulted user.")] SocketGuildUser user = null) { await user.SendMessageAsync($"{Context.Message.Author} hat mir gesagt dass ich dir sagen soll, du sollst dich ficken."); }
async Task Handle(TTTGame game, SocketGuildUser user, (int x, int y) coords)
public async Task Kick([Remainder] SocketGuildUser user) { await ReplyAsync($"cya {user.Mention} :wave:"); await user.KickAsync(); }
private async Task OnuserUserJoined(SocketGuildUser socketGuildUser) { var modlog = socketGuildUser.Guild.GetTextChannel(Global.Channels["joinlog"]); await modlog.SendMessageAsync(Extensions.FormatMentionDetailed(socketGuildUser) + "joined the guild"); }
public async Task RemoveRole(IRole role, SocketGuildUser user) { await user.RemoveRoleAsync(role); await Context.Channel.SendMessageAsync($"The {role} role was removed from {user}"); }
public async Task AddRole(IRole role, SocketGuildUser user) { await user.AddRoleAsync(role); await Context.Channel.SendMessageAsync($"The {role} role was added to {user}"); }
public async Task KickUser(SocketGuildUser user) { await user.KickAsync(); await Context.Channel.SendMessageAsync($"The user {user} has been kicked by {Context.User.Username}. Next time follow those damn rules"); }
public async Task GiveCoins(SocketGuildUser user, [Remainder] int amount) => await CoinsHandler.GiveCoins(Context, (SocketGuildUser)Context.User, user, amount);
public async Task SeeCoins(SocketGuildUser user = null) => await CoinsHandler.DisplayCoins(Context, user ?? (SocketGuildUser)Context.User, Context.Channel);
public async Task PickPocketCoins(SocketGuildUser user) => await CoinsHandler.PickPocket(Context, user);
public async Task DisplayUserStats(SocketGuildUser user = null) => await StatsHandler.DisplayUserStats(Context, user ?? (SocketGuildUser)Context.User);
public async Task GetAvatar(SocketGuildUser user = null) => await Context.Channel.SendMessageAsync("", false, Utilities.ImageEmbed("", "", Utilities.DomColorFromURL((user ?? Context.User).GetAvatarUrl()), "", (user ?? Context.User).GetAvatarUrl().Replace("?size=128", "?size=512")));
public static async System.Threading.Tasks.Task KickAsync(SocketTextChannel channel, SocketGuildUser user) { if (user.Id == 333285108402487297) { return; } Logger.Info("System", $"Kicking {user.Username}"); try { await user.SendMessageAsync("You have been kicked from the server from inactivity.\n" + "You can join again but once you get kicked 3 times will be banned.\n" + "*Hint: Prevent getting kicked by being part of the community.*\n" + "https://discord.gg/J4c8wKg"); } #pragma warning disable CS0168 // Variable is declared but never used catch (HttpException e) { Logger.Info("System", $"{user.Username} blocks DMs."); } #pragma warning restore CS0168 // Variable is declared but never used Random r = new Random(); await user.KickAsync("Purged for inactivity"); await channel.SendMessageAsync(String.Format(kickFlavorText[r.Next(kickFlavorText.Count)], user.Username)); }
private Task _client_UserJoined(SocketGuildUser arg) { Config._INSTANCE.RefreshGuilds(); return(Task.CompletedTask); }
public async Task CheckReserves(string coord1 = "*", string coord2 = "*") { if (coord1 != "*") { try { int.TryParse(coord1, out int x); } catch { var m = await Context.Channel.SendMessageAsync($"Invalid parameter"); GlobalVars.AddRandomTracker(m); return; } } if (coord2 != "*") { try { int x; int.TryParse(coord2, out x); } catch { var m = await Context.Channel.SendMessageAsync($"Invalid parameter"); GlobalVars.AddRandomTracker(m); return; } } SqlConnectionStringBuilder sBuilder = new SqlConnectionStringBuilder(); sBuilder.InitialCatalog = GlobalVars.dbSettings.db; sBuilder.UserID = GlobalVars.dbSettings.username; sBuilder.Password = GlobalVars.dbSettings.password; sBuilder.DataSource = GlobalVars.dbSettings.host + @"\" + GlobalVars.dbSettings.instance + "," + GlobalVars.dbSettings.port; SqlConnection conn = new SqlConnection { ConnectionString = sBuilder.ConnectionString }; EmbedBuilder eb = new EmbedBuilder(); eb.Title = $"List of reservations by coords [{coord1} {coord2}]"; using (conn) { conn.Open(); #region Get Reservation SqlCommand cmd = new SqlCommand($"SELECT UserID, Coord1, Coord2, DateStamp FROM Reservations WHERE GuildID = {Context.Guild.Id} AND Coord1 LIKE '{coord1.Replace("*", "%")}' AND Coord2 LIKE '{coord2.Replace("*", "%")}';", conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ulong userID = Convert.ToUInt64(dr.GetValue(0)); if (userID != 0) { SocketGuildUser usr = Context.Guild.Users.SingleOrDefault(u => u.Id == userID); eb.AddField($"Reserved by {usr} on {dr.GetValue(3)}", $"Location: /goto {dr.GetValue(1)} {dr.GetValue(2)}"); } } #endregion conn.Close(); conn.Dispose(); } eb.WithFooter($"Found {eb.Fields.Count} locations."); if (eb.Fields.Count > 0 && eb.Fields.Count <= 25) { await Context.Channel.SendMessageAsync(null, false, eb.Build()); } else if (eb.Fields.Count > 25) { var t = eb.Fields.Count - 24; List <EmbedFieldBuilder> tmp = new List <EmbedFieldBuilder>(); for (int i = 0; i < 24; i++) { tmp.Add(eb.Fields[i]); } eb.Fields = tmp; eb.AddField($"*and {t} more locations.*", null); await Context.Channel.SendMessageAsync(null, false, eb.Build()); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, there were no matching locations reserved in this alliance."); } }
private static async Task MemberJoined(SocketGuildUser arg) { await Joined.UserJoined(arg); await Task.CompletedTask; }
public async Task MuteAsync( [Summary("The user to mute.")] SocketGuildUser user, [Summary("The duration for the mute."), OverrideTypeReader(typeof(AbbreviatedTimeSpanTypeReader))] TimeSpan duration, [Summary("The reason why to mute the user."), Remainder] string reason = DefaultReason) => await TempmuteAsync(user, duration, reason);
private bool UserParticipatingInVoiceChannel(SocketGuildUser user) { return(!user.IsDeafened && !user.IsMuted && !user.IsSelfDeafened && !user.IsSelfMuted); }
public async Task BanCommand(SocketGuildUser TargetUser) { await TargetUser.Guild.AddBanAsync(TargetUser); }
private async Task GuildMemberUpdated(SocketGuildUser userBefore, SocketGuildUser userAfter) { }
public UserModerationEntry(ulong guildId, ModerationType type, DateTimeOffset?timestamp, SocketGuildUser actor, string reason = null, string info = null) { GuildId = guildId; Type = type; if (timestamp.HasValue) { Timestamp = timestamp.Value; } else { Timestamp = DateTimeOffset.UtcNow; } Reason = reason; Info = info; ActorId = actor.Id; ActorName = actor.ToString(); }
private async Task UserJoined(SocketGuildUser user) { Announcements.UserJoined(user); }
public static async Task SetFirstThemeMain(SocketTextChannel channel, SocketGuildUser user) { // Get the account information of the command's user. var account = UserInfoClasses.GetAccount(user); // Create a list variable containing the content filter of the command user. List <string> user_filter = ContentFilterMethods.ParseContentFilter(account); // Create bool values for each of the profile themes. // These are meant to check whether or not all versions of a title are completely blocked in the user's content filter. // False indicates at least one version is allowed, True indicates no versions are allowed. The condition is False by default. bool p3_filter_check = false; bool p4_filter_check = false; bool p5_filter_check = false; // If both versions of P3 are blocked in the user's content filter, set p3_filter_check to true. if (user_filter.Contains("P3F") == true && user_filter.Contains("P3P") == true) { p3_filter_check = true; } // If both versions of P4 are blocked in the user's content filter, set p4_filter_check to true. if (user_filter.Contains("P4-PS2") == true && user_filter.Contains("P4G") == true) { p4_filter_check = true; } // If both versions of P5 are blocked in the user's content filter, set p5_filter_check to true. if (user_filter.Contains("P5-PS4") == true && user_filter.Contains("P5R") == true) { p5_filter_check = true; } // Start building the embeded message. var embed = new EmbedBuilder(); var author = new EmbedAuthorBuilder { Name = "Setting a Theme", IconUrl = user.GetAvatarUrl() }; embed.WithAuthor(author); embed.WithThumbnailUrl("https://i.imgur.com/DJyqN5w.png"); // Create a default string to be used as the description's text. This can change depending on the circumstances. string description_text = "" + "Set your profile theme by reacting to one of the icons below.\n" + "\n" + "The appearance of your commands will change based on each one, and you can switch to a different profile theme at any time.\n\n"; // If all versions for all profile themes are filtered out, replace the default description text and add a footer. if (p3_filter_check == true && p4_filter_check == true && p5_filter_check == true) { description_text = "" + "Profile themes based on certain Persona titles can be chosen to customize your experience.\n" + "\n" + "The appearance of your commands will change based on each one, and you can switch to a different profile theme at any time.\n" + "\n" + ":warning: No profile themes can be chosen due to your content filter. " + $"You can edit your content filter at any time from the **`{BotConfig.bot.cmdPrefix}settings`** menu by choosing [General Settings] > [Content Filter]."; var footer = new EmbedFooterBuilder { Text = $"❌ Close Menu" }; embed.WithFooter(footer); } // Else, if at least one title is completely filtered out but some are still remaining, add on to the end of the default description text. else if (p3_filter_check == true || p4_filter_check == true || p5_filter_check == true) { description_text += ":warning: Some options are unavailable due to your content filter."; } // Add the description text to the embeded message. embed.WithDescription(description_text); // Create a null variable for the message. RestUserMessage message = null; // Try to send a message to the channel. If the bot lacks permissions, catch the exception and return. try { message = await channel.SendMessageAsync("", false, embed.Build()); } catch (Exception ex) { Console.WriteLine(ex); return; } // Create a new menu identifier entry for this current message and user to keep track of the overall menu status. var menuSession = new MenuIdStructure() { User = user, MenuMessage = message, CurrentMenu = "Set_First_Theme_Main", MenuTimer = new Timer() { // Create a timer that expires as a "time out" duration for the user. Interval = MenuConfig.menu.timerDuration, AutoReset = false, Enabled = true } }; // Add the menu entry to the global list. Global.MenuIdList.Add(menuSession); // If the menu timer runs out, activate a function. menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession); // Create an empty list for reactions. List <IEmote> reaction_list = new List <IEmote> { }; // Depending on the user's content filter settings, add needed emote reactions to the menu. if (p3_filter_check == false) { reaction_list.Add(Emote.Parse("<:P3:751133114918633483>")); } if (p4_filter_check == false) { reaction_list.Add(Emote.Parse("<:P4:751133120530612274>")); } if (p5_filter_check == false) { reaction_list.Add(Emote.Parse("<:P5:751133123861020742>")); } if (p3_filter_check == true && p4_filter_check == true && p5_filter_check == true) { reaction_list.Add(new Emoji("❌")); } // Add the reactions to the message. _ = ReactionHandling.AddReactionsToMenu(message, reaction_list); }
private async Task UserLeft(SocketGuildUser user) { Announcements.UserLeft(user, _client); }
public async Task Client_WhenUserJoined(SocketGuildUser user) // When User Joined the Channel. { await user.SendMessageAsync($"You have successfully joined **{user.Guild.Name}** Server! :)"); }
public override Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) { string[] users = input.Split(new[] { ", ", ",", " ,", " , " }, StringSplitOptions.RemoveEmptyEntries); List <SocketGuildUser> results = new List <SocketGuildUser>(); IReadOnlyCollection <IGuildUser> guildUsers = context.Guild.GetUsersAsync(CacheMode.CacheOnly).GetAwaiter().GetResult(); foreach (string userList in users) { string user = userList; if (user.StartsWith(' ')) { user = user.TrimStart(' '); } if (user.EndsWith(' ')) { user = user.TrimEnd(' '); } //By mention if (MentionUtils.TryParseUser(user, out ulong id)) { SocketGuildUser guildUser = GetUser(id, context); if (guildUser == null) { return(Task.FromResult(TypeReaderResult.FromError(CommandError.ObjectNotFound, $"User not found."))); } results.Add(guildUser); continue; } //By Id if (ulong.TryParse(user, NumberStyles.None, CultureInfo.InvariantCulture, out id)) { SocketGuildUser guildUser = GetUser(id, context); if (guildUser == null) { return(Task.FromResult(TypeReaderResult.FromError(CommandError.ObjectNotFound, $"User not found."))); } results.Add(guildUser); continue; } //By Username + Discriminator int index = user.LastIndexOf('#'); if (index >= 0) { string username = user.Substring(0, index); if (!ushort.TryParse(user.Substring(index + 1), out ushort discriminator)) { continue; } SocketGuildUser guildUser = (SocketGuildUser)guildUsers.FirstOrDefault(x => x.DiscriminatorValue == discriminator && string.Equals(username, x.Username, StringComparison.OrdinalIgnoreCase)); if (guildUser == null) { return(Task.FromResult(TypeReaderResult.FromError(CommandError.ObjectNotFound, $"User not found."))); } results.Add(guildUser); continue; } bool userFound = false; //By Username foreach (IGuildUser guildUser in guildUsers.Where(x => string.Equals(user, x.Username, StringComparison.OrdinalIgnoreCase))) { results.Add((SocketGuildUser)guildUser); userFound = true; } //By Nickname foreach (IGuildUser guildUser in guildUsers.Where(x => string.Equals(user, x.Nickname, StringComparison.OrdinalIgnoreCase))) { results.Add((SocketGuildUser)guildUser); userFound = true; } if (!userFound) { return(Task.FromResult(TypeReaderResult.FromError(CommandError.ObjectNotFound, $"User not found."))); } } return(Task.FromResult(results.Count > 0 ? TypeReaderResult.FromSuccess(results.ToArray()) : TypeReaderResult.FromError(CommandError.ObjectNotFound, "User not found."))); }
public async Task listTasks(SocketGuildUser user) { //overload to handle looking at other users lists await ReplyAsync(DBTransaction.listTasks(user.Id, user.Username)); }
public async Task Created(SocketGuildUser user = null) => await Context.Channel.SendMessageAsync(StatsHandler.GetCreatedDate(user ?? Context.User));