コード例 #1
0
        protected async Task AddTestCommands(bool doit = false)
        {
            if (doit)
            {
                Channel chann;
                chann = await ChannelService.FirstAsync(c => c.Name == BotName);

                if (await CommandService.CountAsync() < 4)
                {
                    var comm1 = new Command
                    {
                        CreatedAt        = DateTime.UtcNow,
                        PublicResponse   = true,
                        TypeCommand      = "++s",
                        Action           = "/subscribers",
                        CreatedBy        = chann,
                        Name             = "Subscribers mode on",
                        IsSpecialCommand = true,
                        Operators        = TwitchBadges.LocalBadges.Moderator | TwitchBadges.LocalBadges.Broadcaster,
                    };

                    await CommandService.AddAsync(comm1);

                    var comm2 = new Command
                    {
                        CreatedAt        = DateTime.UtcNow,
                        PublicResponse   = true,
                        TypeCommand      = "--s",
                        Action           = "/subscribersoff",
                        CreatedBy        = chann,
                        Name             = "Subscribers mode off",
                        IsSpecialCommand = true,
                        Operators        = TwitchBadges.LocalBadges.Moderator | TwitchBadges.LocalBadges.Broadcaster,
                    };

                    await CommandService.AddAsync(comm2);

                    var comm3 = new Command
                    {
                        CreatedAt        = DateTime.UtcNow,
                        PublicResponse   = true,
                        TypeCommand      = "++e",
                        Action           = "/emoteonly",
                        CreatedBy        = chann,
                        Name             = "Emote only",
                        IsSpecialCommand = true,
                        Operators        = TwitchBadges.LocalBadges.Moderator | TwitchBadges.LocalBadges.Broadcaster,
                    };

                    await CommandService.AddAsync(comm3);

                    var comm4 = new Command
                    {
                        CreatedAt        = DateTime.UtcNow,
                        PublicResponse   = true,
                        TypeCommand      = "--e",
                        Action           = "/emoteonlyoff",
                        CreatedBy        = chann,
                        Name             = "Emote only off",
                        IsSpecialCommand = true,
                        Operators        = TwitchBadges.LocalBadges.Moderator | TwitchBadges.LocalBadges.Broadcaster,
                    };

                    await CommandService.AddAsync(comm4);
                }
            }
        }