Пример #1
0
        public async Task TagAsync(string name)
        {
            var      guild = RavenDb.GetGuild(Context.Guild.Id);
            RavenTag tag   = guild.Tags.Find(x => string.Equals(x.Tag, name, StringComparison.CurrentCultureIgnoreCase));

            if (tag is null)
            {
                await ReplyAsync("The specified tag couldn't be found.");

                return;
            }

            await ReplyAsync($"{tag.Tag} ({tag.Category}):\n{tag.Message}");
        }
Пример #2
0
        private static Task <RestUserMessage> AddTag(RavenGuild guild, ulong userId, SocketTextChannel channel,
                                                     string[] args)
        {
            string name     = args.ElementAtOrDefault(1);
            string category = args.ElementAtOrDefault(2);

            if (name is null)
            {
                return(channel.SendMessageAsync(GetMissingParam("TagName", typeof(string))));
            }

            if (guild.Tags.Any(x => string.Equals(x.Tag, name, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(channel.SendMessageAsync("Specified tag name already exists."));
            }

            if (category is null)
            {
                return(channel.SendMessageAsync(GetMissingParam("TagCategory", typeof(string))));
            }

            if (args.ElementAtOrDefault(3) is null)
            {
                return(channel.SendMessageAsync(GetMissingParam("TagMessage", typeof(string))));
            }

            string   message = string.Join(" ", args.Skip(3));
            RavenTag tag     = new RavenTag
            {
                AuthorId = userId,
                Category = category,
                Tag      = name,
                Message  = message
            };

            guild.Tags.Add(tag);
            guild.Save();
            return(SelectSubMenu(guild, userId, channel, MessageBox.TagSettings));
        }