コード例 #1
0
        public async ValueTask CreateReactionAsync(DiscordEmoji emoji)
        {
            var user = await Client.GetSelfAsync();

            if (Reactions.Any(r => r.Emoji.Id == emoji.Id && r.UserId == user.Id))
            {
                return;
            }

            Reactions.Add(new TestReaction
            {
                Emoji  = emoji,
                UserId = user.Id
            });
        }
コード例 #2
0
        public override string ToString()
        {
            var sb = new StringBuilder(string.Format("; {0}\n\n(import (rnrs) (emodl cmslib))\n\n(start-model \"{0}\")\n\n", Name));

            if (Constraints.Any())
            {
                foreach (var constraint in Constraints)
                {
                    sb.AppendLine(constraint.ToString());
                }

                sb.AppendLine();
            }

            if (ScheduledEvents.Any())
            {
                foreach (var evt in ScheduledEvents)
                {
                    sb.AppendLine(evt.ToString());
                }

                sb.AppendLine();
            }

            if (TriggeredEvents.Any())
            {
                foreach (var evt in TriggeredEvents)
                {
                    sb.AppendLine(evt.ToString());
                }

                sb.AppendLine();
            }

            var expressions = Expressions.Where(e => (e.Name != null && e.Name != "rand"));

            if (expressions.Any())
            {
                foreach (var expression in expressions)
                {
                    sb.AppendLine(expression.ToString());
                }

                sb.AppendLine();
            }

            if (Observables.Any())
            {
                foreach (var observable in Observables)
                {
                    sb.AppendLine(observable.ToString());
                }

                sb.AppendLine();
            }

            var parameters = Parameters.Where(p => (p.Name != "time" && p.Name != "pi"));

            if (parameters.Any())
            {
                foreach (var parameter in parameters)
                {
                    sb.AppendLine(parameter.ToString());
                }

                sb.AppendLine();
            }

            var predicates = Predicates.Where(p => p.Name != null);

            if (predicates.Any())
            {
                foreach (var predicate in predicates)
                {
                    sb.AppendLine(predicate.ToString());
                }

                sb.AppendLine();
            }

            foreach (var locale in Locales)
            {
                if (locale.Name != "global")
                {
                    sb.AppendLine(locale.ToString());
                    sb.AppendLine(string.Format("(set-locale {0})\n", locale.Name));
                }
                var currentLocale = locale;
                foreach (var species in Species.Where(s => s.Locale == currentLocale))
                {
                    sb.AppendLine(species.ToString());
                }
                sb.AppendLine();
            }

            if (Reactions.Any())
            {
                foreach (var reaction in Reactions)
                {
                    sb.AppendLine(reaction.ToString());
                }

                sb.AppendLine();
            }

            sb.Append("(end-model)");

            return(sb.ToString());
        }