public async Task Bean(IGuildUser user, [Remainder] string reason = null) { using var Database = new SkuldDbContextFactory().CreateDbContext(); var usr = Database.Users.Find(user.Id); if (usr.Flags.IsBitSet(DiscordUtilities.Banned)) { usr.Flags -= DiscordUtilities.Banned; usr.BanReason = null; await EmbedExtensions.FromSuccess(SkuldAppContext.GetCaller(), $"Un-beaned {user.Mention}", Context) .QueueMessageAsync(Context).ConfigureAwait(false); } else { if (reason == null) { await EmbedExtensions.FromError($"{nameof(reason)} needs a value", Context) .QueueMessageAsync(Context).ConfigureAwait(false); return; } usr.Flags += DiscordUtilities.Banned; usr.BanReason = reason; await EmbedExtensions.FromSuccess(SkuldAppContext.GetCaller(), $"Beaned {user.Mention} for reason: `{reason}`", Context) .QueueMessageAsync(Context).ConfigureAwait(false); } await Database.SaveChangesAsync().ConfigureAwait(false); }
public async Task Shrug() { var images = await Imghoard.GetImagesAsync(SkuldAppContext.GetCaller().LowercaseFirstLetter()).ConfigureAwait(false); var image = images.Images.RandomValue().Url; await new EmbedBuilder() .WithImageUrl(image) .WithTitle(SkuldAppContext.GetCaller()) .WithDescription($"{Context.User.Mention} shrugs") .WithRandomColor() .AddAuthor(Context.Client) .AddFooter(Context) .QueueMessageAsync(Context).ConfigureAwait(false); }
public async Task Stab([Remainder] string target = null) { var images = await Imghoard.GetImagesAsync(SkuldAppContext.GetCaller().LowercaseFirstLetter()).ConfigureAwait(false); var image = images.Images.RandomValue().Url; var action = DoAction( image, SkuldAppContext.GetCaller(), GetMessage(target, $"{Context.Client.CurrentUser.Mention} stabs {target}", $"{Context.User.Mention} stabs {target}" ) ); await action.QueueMessageAsync(Context).ConfigureAwait(false); }
public async Task Kiss([Remainder] string target = null) { var images = await Imghoard.GetImagesAsync(SkuldAppContext.GetCaller().LowercaseFirstLetter()).ConfigureAwait(false); var image = images.Images.Random().Url; var action = DoAction( image, SkuldAppContext.GetCaller(), GetMessage(target, $"I-it's not like I like you or anything... {Context.Client.CurrentUser.Mention} kisses {Context.User.Mention}", $"{Context.User.Mention} kisses {target}" ) ); await action.QueueMessageAsync(Context).ConfigureAwait(false); }
public async Task Pet([Remainder] string target = null) { var images = await Imghoard.GetImagesAsync(SkuldAppContext.GetCaller().LowercaseFirstLetter()).ConfigureAwait(false); var image = images.Images.RandomValue().Url; var action = new EmbedBuilder() .WithImageUrl(image) .WithTitle(SkuldAppContext.GetCaller().CapitaliseFirstLetter()) .WithRandomColor() .AddAuthor(Context.Client) .AddFooter(Context); if (target != null) { if (Context.Message.MentionedUsers.Any()) { List <ulong> prune = new List <ulong>(); { using SkuldDbContext Database = new SkuldDbContextFactory().CreateDbContext(null); foreach (var mentionedUser in Context.Message.MentionedUsers) { var res = Database.BlockedActions.FirstOrDefault(x => x.Blockee == Context.User.Id && x.Blocker == mentionedUser.Id); if (res != null) { prune.Add(mentionedUser.Id); } } } { using SkuldDbContext Database = new SkuldDbContextFactory().CreateDbContext(null); var initiator = await Database.InsertOrGetUserAsync(Context.User).ConfigureAwait(false); StringBuilder message = new StringBuilder($"{Context.User.Mention} pets "); var msg = target; foreach (var usr in Context.Message.MentionedUsers) { if (usr.IsBot || usr.IsWebhook || usr.Discriminator == "0000" || usr.DiscriminatorValue == 0 || prune.Contains(usr.Id)) { continue; } var uzr = await Database.InsertOrGetUserAsync(usr).ConfigureAwait(false); if (!(uzr.RecurringBlock && uzr.Patted.IsRecurring(3))) { uzr.Patted += 1; initiator.Pats += 1; message.Append(usr.Mention + " "); } else { msg.PruneMention(usr.Id); } } await Database.SaveChangesAsync().ConfigureAwait(false); if (message.ToString() != $"{Context.User.Mention} pets ") { action.WithDescription(message.ToString()); } else { action.WithDescription($"{Context.Client.CurrentUser.Mention} pets {Context.User.Mention}"); } } } else { action.WithDescription($"{Context.User.Mention} pets {target}"); } } else { action.WithDescription($"{Context.Client.CurrentUser.Mention} pets {Context.User.Mention}"); } await action.QueueMessageAsync(Context).ConfigureAwait(false); }
private static async Task Bot_ReactionAdded( Cacheable <IUserMessage, ulong> arg1, ISocketMessageChannel arg2, SocketReaction arg3) { DogStatsd.Increment("messages.reactions.added"); IUser usr; var msg = await arg1.GetOrDownloadAsync().ConfigureAwait(false); if (msg == null) { return; } if (!arg3.User.IsSpecified) { return; } else { usr = arg3.User.Value; } if (usr.IsBot || usr.IsWebhook) { return; } if (arg2 is IGuildChannel) { await PinningService.ExecuteAdditionAsync(SkuldApp.DiscordClient, SkuldApp.Configuration, msg, arg2) .ConfigureAwait(false); await StarboardService.ExecuteAdditionAsync(msg, arg2, arg3) .ConfigureAwait(false); } if (arg2.Id == SkuldApp.Configuration.IssueChannel) { using var Database = new SkuldDbContextFactory() .CreateDbContext(); var user = await Database.InsertOrGetUserAsync(usr) .ConfigureAwait(false); if (user.Flags.IsBitSet(DiscordUtilities.BotCreator)) { try { if (arg1.HasValue) { var message = Database.Issues .FirstOrDefault(x => x.IssueChannelMessageId == arg1.Id ); if (message != null) { var emote = arg3.Emote as Emote; if (emote.Id == DiscordUtilities.Tick_Emote.Id) { if (!message.HasSent) { try { var newissue = new NewIssue(message.Title) { Body = message.Body }; newissue. Assignees.Add("exsersewo"); newissue. Labels.Add("From Command"); var issue = await SkuldApp .Services .GetRequiredService <GitHubClient>() .Issue .Create( SkuldApp .Configuration .GithubRepository, newissue ).ConfigureAwait(false); try { await SkuldApp.DiscordClient .GetUser( message.SubmitterId ) .SendMessageAsync( "", false, new EmbedBuilder() .WithTitle( "Good News!" ) .AddAuthor( SkuldApp .DiscordClient ) .WithDescription( "Your issue:\n" + $"\"[{newissue.Title}]" + $"({issue.HtmlUrl})\"" + "\n\nhas been accepted" ) .WithRandomColor() .Build() ).ConfigureAwait(false); } catch { } await msg.ModifyAsync(x => { x.Embed = msg.Embeds .ElementAt(0) .ToEmbedBuilder() .AddField( "Sent", DiscordUtilities .Tick_Emote .ToString() ) .Build(); }).ConfigureAwait(false); message.HasSent = true; await Database.SaveChangesAsync() .ConfigureAwait(false); } catch (Exception ex) { Log.Error( "Git-" + SkuldAppContext.GetCaller(), ex.Message, null, ex ); } } } else if ( emote.Id == DiscordUtilities.Cross_Emote.Id ) { Database.Issues.Remove(message); await Database.SaveChangesAsync() .ConfigureAwait(false); await msg.DeleteAsync() .ConfigureAwait(false); try { await SkuldApp .DiscordClient .GetUser(message.SubmitterId) .SendMessageAsync( "", false, new EmbedBuilder() .WithTitle("Bad News") .AddAuthor( SkuldApp.DiscordClient ) .WithDescription( "Your issue:\n" + $"\"{message.Title}\"" + "\n\nhas been declined. " + "If you would like to know why, " + $"send: {usr.FullName()} a message" ) .WithRandomColor() .Build() ).ConfigureAwait(false); } catch { } } } } } catch (Exception ex) { Log.Critical(Key, ex.Message, null, ex ); } } } }