Exemple #1
0
        public async Task <StreamerChannelSettingsViewModel> GetChannelSettingsAnnouncer(
            [FromServices] IDiscordUserGuildService userGuildService,
            [FromServices] IModuleSettingsService <StreamerSettings> streamerSettingsService, ulong guildId,
            ulong channelId)
        {
            // All channel's settings in guild.
            var allChannelSettings = await streamerSettingsService.GetSettingsByGuild(guildId, x => x.ChannelSettings);

            if (allChannelSettings == null)
            {
                return new StreamerChannelSettingsViewModel
                       {
                           Enabled        = false,
                           RemoveMessages = false
                       }
            }
            ;

            // Settings for specific channel.
            var channelSettings = allChannelSettings.ChannelSettings.FirstOrDefault(x => x.ChannelId == channelId);

            var isEnabled = channelSettings != null;

            var settings = new StreamerChannelSettingsViewModel
            {
                Enabled        = isEnabled,
                RemoveMessages = isEnabled && channelSettings.RemoveMessage
            };

            return(settings);
        }
Exemple #2
0
        public async Task <object> GetUserAdminGuilds([FromServices] IDiscordUserGuildService userGuildService)
        {
            var guilds = await userGuildService.GetUserGuilds();

            // Format the ulong to string.
            return(guilds.FilterAdministrator().Select(g => new { id = g.Guild.Id.ToString(), name = g.Guild.Name }));
        }
        // GET
        public async Task <IActionResult> StreamAnnouncerSettings([FromServices] IDiscordUserGuildService userGuildService,
                                                                  [FromServices] IBot bot)
        {
            var userGuilds = await userGuildService.GetUserGuilds();

            var botGuilds = bot.GetGuilds();

            var userAdminGuilds = userGuilds.FilterAdministrator().Select(g => g.Guild);

            var viewModel = new StreamAnnouncerSettingsViewModel
            {
                Guilds = new SelectList(userAdminGuilds.FilterGuildsByIds(botGuilds.Select(b => b.Id).ToList()), "Id", "Name")
            };

            return(View(viewModel));
        }
Exemple #4
0
        public async Task <object> GetUserAdminGuilds([FromServices] IDiscordUserGuildService userGuildService,
                                                      [FromServices] IBot bot, bool inGuild = false)
        {
            var guilds = await userGuildService.GetUserGuilds();

            if (inGuild)
            {
                guilds.RemoveAll(g => !bot.IsBotInGuild(g.Guild.Id));
            }

            // Format the ulong to string.
            return(guilds.FilterAdministrator().Select(g => new
            {
                id = g.Guild.Id.ToString(),
                name = g.Guild.Name,
                icon = g.Guild.Icon
            }));
        }
Exemple #5
0
 public DashboardController(IDiscordUserGuildService userGuildService, IDiscordGuildService guildService, IBot bot)
 {
     _userGuildService = userGuildService;
     _guildService     = guildService;
     _bot = bot;
 }