public async Task RemoveEmoteAsync( [Summary(":nice:")] GuildEmote emote) { await Context.Guild.DeleteEmoteAsync(emote); await Context.ReplyAsync("You have successfully removed this emote."); }
public Embed GetDiscordEmbed(LocaleSetting locale, out GuildEmote subEmote, out GuildEmote specialEmote, SocketGuild guild) { try { Image img = new Image(WebRequest.Create(GetSubWeapon().GetImageUrl()).GetResponse().GetResponseStream()); subEmote = guild.CreateEmoteAsync(Name, img).GetAwaiter().GetResult(); } catch { subEmote = null; } try { Image img = new Image(WebRequest.Create(GetSpecialWeapon().GetImageUrl()).GetResponse().GetResponseStream()); specialEmote = guild.CreateEmoteAsync(Name, img).GetAwaiter().GetResult(); } catch { specialEmote = null; } Embed eb = new EmbedBuilder() .WithTitle(GetName(locale)) .WithThumbnailUrl(GetImageUrl()) .WithColor(new Color(0x00, 0xFF, 0x00)) .AddField("Sub Weapon", (subEmote == null ? "" : $"{subEmote} ") + $"*{GetSubWeapon().GetName(locale)}*") .AddField("Special", (specialEmote == null ? "" : $"{specialEmote} ") + $"*{GetSpecialWeapon().GetName(locale)}*") .AddField(Data.Locales[(int)locale].First(x => x.Key == Param0).Value, $"{ASCIIUI.CreateTextBar(ParamValue0, 100)} **[{ParamValue0}/100]**") .AddField(Data.Locales[(int)locale].First(x => x.Key == Param1).Value, $"{ASCIIUI.CreateTextBar(ParamValue1, 100)} **[{ParamValue1}/100]**") .AddField(Data.Locales[(int)locale].First(x => x.Key == Param2).Value, $"{ASCIIUI.CreateTextBar(ParamValue2, 100)} **[{ParamValue2}/100]**") .Build(); return(eb); }
public static bool DiscordEmoteExist(BotChannel bChan, string emote) { GuildEmote gEmote = Program.DiscordClient.GetGuild(bChan.GuildID).Emotes.FirstOrDefault(x => x.Name == emote); if (gEmote != null) { return(true); } return(false); }
public static bool TryGetEmote(this SocketGuild guild, string name, out GuildEmote emote) { emote = null; if (!guild.Emotes.Any(x => x.HasName(name))) { return(false); } emote = guild.Emotes.Where(x => x.HasName(name)).First(); return(true); }
public static bool TryGetEmote(this SocketGuild guild, ulong id, out GuildEmote emote) { emote = null; if (!guild.Emotes.Any(x => x.HasId(id))) { return(false); } emote = guild.Emotes.Where(x => x.HasId(id)).First(); return(true); }
private CollectableEntity UpdateEmoteName(CollectableEntity collectable) { GuildEmote emote = _client.Guilds.SelectMany(g => g.Emotes).FirstOrDefault(e => e.Name == collectable.EmoteName); if (emote == null) { return(DefaultCollectable); } collectable.EmoteName = EmoteStringFormat(emote); return(collectable); }
public async Task Emote([Remainder, Summary("")] string emote) { if (string.IsNullOrEmpty(emote)) { throw new ArgumentException("is null or empty", nameof(emote)); } bool e = GuildEmote.TryParse(emote, out Emote emo); if (!e || emo is null) { return; } await ReplyImage(emote.Replace(":", "", System.StringComparison.Ordinal), emo.Url); }
/// <summary> /// Determines whether the current user can access the supplied emoji /// </summary> /// <param name="user">The user for whom to determine emoji access.</param> /// <param name="emoji">The emoji that the user is attempting to access</param> /// <returns>A flag indicating whether the user can access the supplied emoji.</returns> public static bool CanAccessEmoji(this SocketSelfUser user, GuildEmote emoji) { if (user is null) { throw new ArgumentNullException(nameof(user)); } if (emoji is null) { throw new ArgumentNullException(nameof(emoji)); } var accessibleEmotes = user.MutualGuilds.SelectMany(x => x.Emotes); return(accessibleEmotes.Any(x => x.Id == emoji.Id)); }
public static async Task AutoReactAsync(SocketMessage messageParam) { var message = messageParam as SocketUserMessage; if (message == null) { return; } var context = new SocketCommandContext(EntryPoint.Client, message); List <ulong> Plank = new List <ulong>() { 89555451364003840 }; List <ulong> Chronos = new List <ulong>() { }; List <ulong> Smilies = new List <ulong>() { 162120089812860928, 130591078469337088, 338751193440452611 }; if (Plank.Contains(message.Author.Id) && context.Guild.Id == 372226412901564417) { GuildEmote seg = context.Guild.Emotes.FirstOrDefault(em => em.ToString() == "<:plank:393989115772796929>"); await message.AddReactionAsync(seg, null); } if (Chronos.Contains(message.Author.Id) && context.Guild.Id == 372226412901564417) { GuildEmote seg = context.Guild.Emotes.FirstOrDefault(em => em.ToString() == "<:chronojail:392440043974819862>"); await message.AddReactionAsync(seg, null); } if (Smilies.Contains(message.Author.Id) && context.Guild.Id == 372226412901564417) { await message.AddReactionAsync(new Emoji("🙂")); } }
public async Task Neps() { int counter = 0; foreach (var item in Program.Guilds) { counter = counter + item.Value.Nep; } try { var emote = GuildEmote.Parse(Program.nepmote).Url; await ReplyAsync("", false, Embed.GetEmbed("Neps!", $"The current ammount of neps in this server is {counter}, the current amount of neps overall is {Program.Guilds.GetValueOrDefault(Context.Guild.Id).Nep}", await Program.GetUserColour(Context.Message.Author.Id), "Nep Nep", emote)); } catch { await ReplyAsync("", false, Embed.GetEmbed("Neps!", $"There was an error calculating neps")); } }
public async Task AddEmoteCommand(ulong emoteId, [Remainder] string nick = null) { try { GuildEmote em = Context.Client.Guilds.SelectMany(x => x.Emotes).FirstOrDefault(x => x.Id == emoteId); if (em != null) { await AddEmoteToDatabase(em, nick, Context.User.Id); } else { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, emoteId, "Emote associated with the ID", "Discord"); } } catch (Exception) { Defined.BuildErrorMessage(_eBuilder, Context, ErrorTypes.E404, emoteId, "Emote associated with the ID", "Discord"); } await ReplyAsync(string.Empty, embed : _eBuilder.Build()); }
public override async Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) { // a pepeLaughing 588362912494780417 string emoteStr = input .Replace("<", "") .Replace(">", ""); string[] emoteSplits = emoteStr.Split(':'); bool gifEmote = emoteStr.StartsWith("a:"); bool validEmoteId = ulong.TryParse(emoteSplits.LastOrDefault(), out ulong emoteId); if (!validEmoteId) { return(TypeReaderResult.FromError(CommandError.Exception, "Could not parse this Emote's ID from the provided input.")); } string emoteName = emoteSplits[1]; var result = DiscordHelpers.CreateInstance <Emote>(emoteId, emoteName, gifEmote); if (context.Guild.Emotes.FirstOrDefault(x => x.Id == emoteId) == null) { // If a user copy/pastes a msg with an emote in it instead of typing the emote, look for this emote anyway. GuildEmote emoteAltPossibility = context.Guild.Emotes.FirstOrDefault(x => x.Name == emoteName); if (emoteAltPossibility == null) { return(TypeReaderResult.FromError(CommandError.ObjectNotFound, "The current guild does not contain this emote.")); } return(TypeReaderResult.FromSuccess(emoteAltPossibility)); } return(TypeReaderResult.FromSuccess(result)); }
/// <inheritdoc /> public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => SocketGuild.DeleteEmoteAsync(emote);
/// <summary> /// Attempts to get the specified emote in this guild. /// </summary> public static bool TryGetEmote(this IGuild guild, string name, out GuildEmote emote) { emote = guild.Emotes.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); return(emote != null); }
/// <summary> /// Attempts to get the specified emote in this guild. /// </summary> public static bool TryGetEmote(this IGuild guild, ulong id, out GuildEmote emote) { emote = guild.Emotes.FirstOrDefault(x => x.Id == id); return(emote != null); }
public virtual Task <GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions?options = null) { return(_socketGuild.ModifyEmoteAsync(emote, func, options)); }
public virtual Task DeleteEmoteAsync(GuildEmote emote, RequestOptions?options = null) { return(_socketGuild.DeleteEmoteAsync(emote, options)); }
public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) { return(Guild.DeleteEmoteAsync(emote, options)); }
public Task <GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null) { return(Guild.ModifyEmoteAsync(emote, func, options)); }
/// <inheritdoc /> /// <exception cref="ArgumentNullException"><paramref name="func"/> is <c>null</c>.</exception> public Task <GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null) => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options);
/// <inheritdoc /> public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => RestGuild.DeleteEmoteAsync(emote, options);
public static string ToMessageString(this GuildEmote emoji) => $"<{emoji.ToIdString()}>";
public Task <GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null) { throw new NotImplementedException(); }
public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) { throw new NotImplementedException(); }
public static string ToIdString(this GuildEmote emoji) => $":{emoji.Name}:{emoji.Id}";
/// <inheritdoc /> Task <GuildEmote> IGuild.ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions options) => (SocketGuild as IGuild).ModifyEmoteAsync(emote, func, options);
/// <inheritdoc /> public Task <GuildEmote> ModifyEmoteAsync(GuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null) => (RestGuild as IGuild).ModifyEmoteAsync(emote, func, options);
public async Task HeadpatCommand([Optional] IGuildUser User) { if (User == null) { User = Context.Guild.GetUser(Context.User.Id); } string NameOfUser = Regex.Replace(User.Username, "[^a-zA-Z]", "", RegexOptions.Compiled); if (NameOfUser.Length < 2) { NameOfUser = "******"; } string ImageCacheDir = Path.Combine(Directory.GetCurrentDirectory(), "ImageCache"); if (!Directory.Exists(ImageCacheDir)) { Directory.CreateDirectory(ImageCacheDir); } string FilePath = Path.Join(ImageCacheDir, $"{NameOfUser}.gif"); using (AnimatedGifCreator Gif = AnimatedGif.AnimatedGif.Create(FilePath, 80)) { string[] Files = Directory.GetFiles(FunConfiguration.HeadpatsDir, "*.png", SearchOption.AllDirectories); using WebClient WebClient = new(); using MemoryStream MemoryStream = new(WebClient.DownloadData(User.GetTrueAvatarUrl())); using Image PFPImage = Image.FromStream(MemoryStream); for (int Index = 0; Index < Files.Length; Index++) { using Image Headpat = Image.FromFile(Files[Index]); using Bitmap DrawnImage = new(Headpat.Width, Headpat.Height); List <ushort> HeadpatPos = FunConfiguration.HeadpatPositions[Index]; using (Graphics Graphics = Graphics.FromImage(DrawnImage)) { Graphics.DrawImage(PFPImage, HeadpatPos[0], HeadpatPos[1], HeadpatPos[2], HeadpatPos[3]); Graphics.DrawImage(Headpat, 0, 0); } await Gif.AddFrameAsync(DrawnImage, delay : -1, quality : GifQuality.Bit8); } } using (Discord.Image EmoteImage = new (FilePath)) { IGuild Guild = DiscordSocketClient.GetGuild(FunConfiguration.HeadpatStorageGuild); Console.WriteLine(NameOfUser.Length); Console.WriteLine(EmoteImage); GuildEmote PrevEmote = Guild.Emotes.Where(Emote => Emote.Name == NameOfUser).FirstOrDefault(); if (PrevEmote != null) { await Guild.DeleteEmoteAsync(PrevEmote); } GuildEmote Emote = await Guild.CreateEmoteAsync(NameOfUser, EmoteImage); DiscordWebhookClient Webhook = await CreateOrGetWebhook(Context.Channel.Id, FunConfiguration.HeadpatWebhookName); await Webhook.SendMessageAsync( Emote.ToString(), username : string.IsNullOrEmpty(Context.Guild.GetUser(Context.User.Id).Nickname)?Context.User.Username : Context.Guild.GetUser(Context.User.Id).Nickname, avatarUrl : Context.User.GetTrueAvatarUrl() ); await Guild.DeleteEmoteAsync(Emote); } File.Delete(FilePath); }
/// <inheritdoc /> public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options);
public async Task CreateRoleCard(params string[] args) { //await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() //{ // Title = "Sorry bud", // Description = $"This has been disabled bucko", // Color = Color.Red //}.Build()); //return; if (!HasExecutePermission) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "Waaiitt a minute.. who are you?", Description = $"Looks like you dont have permission to execute this command. if this is wrong yell at quin>", Color = Color.Red }.Build()); return; } if (args.Length == 0) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What? where?", Description = $"Looks like you didnt provide a channel :/ do so please!", Color = Color.Red }.Build()); return; } if (args.Length == 1) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What should i add?!", Description = $"Uhhhhh. epic swissbot here, you need to tell me the roles you want to add plus there emoji/description ok bye <3", Color = Color.Red }.Build()); return; } var channel = Context.Message.MentionedChannels.First(); var redargs = args.Skip(1).ToArray(); var tmpRolecard = new RoleCard(); tmpRolecard.ChannelID = channel.Id; tmpRolecard.RoleEmojiIDs = new List <RoleCard.RoleEmoteDesc>(); if (redargs.Any(x => x.Contains(",")))//multiple { int c = 0; var msg = Context.Channel.SendMessageAsync("this message is here to test the emotes... (dont delete)").Result; foreach (var item in string.Join(' ', redargs).Split(", ")) { if (Context.Message.MentionedRoles.Count <= c) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What is that?", Description = "The Role you provided is invalid :/", Color = Color.Red }.Build()); return; } IRole role = Context.Message.MentionedRoles.ToArray()[c]; c++; string emote = item.Split(' ')[1]; string description = string.Join(' ', item.Split(' ').Skip(2)); if (GuildEmote.TryParse(emote, out var outemote)) { tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc() { Description = description, Emote = emote, RoleID = role.Id }); try { await msg.AddReactionAsync(outemote); } catch (Exception ex) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What is that?", Description = "The emote you provided is invalid or is broken :/", Color = Color.Red }.Build()); await msg.DeleteAsync(); return; } //Global.SaveRoleCard(); //await UpdateRoleCard(); } else { var m = new Emoji(emote); try { await msg.AddReactionAsync(m); tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc() { Description = description, Emote = m.Name, RoleID = role.Id }); //Global.SaveRoleCard(); //await UpdateRoleCard(); } catch (Exception ex) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What is that?", Description = "The emote you provided is invalid or is broken :/", Color = Color.Red }.Build()); await msg.DeleteAsync(); return; } } } await msg.ModifyAsync(x => x.Content = "Ok good you used valid emotes <3 card will be created very shortly. ps il delete this in 5 seconds lol"); new Timer() { AutoReset = false, Interval = 5000, Enabled = true }.Elapsed += (object s, ElapsedEventArgs a) => { msg.DeleteAsync().Wait(); }; await DeployCard(tmpRolecard); } else//single { IRole role = Context.Message.MentionedRoles.First(); string emote = redargs[1]; string description = string.Join(' ', redargs.Skip(2)); if (Emote.TryParse(emote, out var outemote)) { tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc() { Description = description, Emote = emote, RoleID = role.Id }); //Global.SaveRoleCard(); //await UpdateRoleCard(); } else { var m = new Emoji(emote); try { var msg = Context.Channel.SendMessageAsync("Testing the emote...").Result; await msg.AddReactionAsync(m); await msg.ModifyAsync(x => x.Content = "Ok good you used a valid emote <3. ps il delete this in 5 seconds lol"); new Timer() { AutoReset = false, Interval = 5000, Enabled = true }.Elapsed += (object s, ElapsedEventArgs a) => { msg.DeleteAsync().Wait(); }; tmpRolecard.RoleEmojiIDs.Add(new RoleCard.RoleEmoteDesc() { Description = description, Emote = m.Name, RoleID = role.Id }); //Global.SaveRoleCard(); //await UpdateRoleCard(); } catch (Exception ex) { await Context.Channel.SendMessageAsync("", false, new EmbedBuilder() { Title = "What is that?", Description = "The emote you provided is invalid or is broken :/", Color = Color.Red }.Build()); return; } } await DeployCard(tmpRolecard); } }