public async Task Notify()
        {
            var status = await _synthbotWebClient.GetDiscordUserStatus(Context.User.Id.ToString());

            await ReplyAsync("", false, EmbedFactory.Notifications.NotifyState(Context, status));

            var userResponse = await NextMessageAsync();

            if (userResponse != null)
            {
                DiscordUserStatus newStatus = default;
                if (userResponse.Content.ToLower() == "yes")
                {
                    newStatus = DiscordUserStatus.RegisteredWithNotify;
                }
                else if (userResponse.Content.ToLower() == "no")
                {
                    newStatus = DiscordUserStatus.RegisteredWithoutNotify;
                }

                if (newStatus != default)
                {
                    await _synthbotWebClient.SetDiscordUserStatus(Context.User.Id.ToString(), newStatus);
                }

                await ReplyAsync("", false, EmbedFactory.Notifications.NotifyUpdate(Context, newStatus, userResponse.Content));
            }
        }
Ejemplo n.º 2
0
        public async Task SetUserStatus(
            [Summary("Possible statuses: NoResponse, IgnoreForever, RemindMeLater, Registered, New")]
            DiscordUserStatus status)
        {
            var response = await _synthbotWebClient.SetDiscordUserStatus(Context.User.Id.ToString(), status);

            await ReplyAsync($"Success: {response}");
        }
        public async Task HandleJoined(SocketUser user, SocketVoiceChannel newChannel)
        {
            // Get user status
            var status = await GetDiscordUserStatus(user.Id);

            var synthbotUser = status != DiscordUserStatus.New || status != DiscordUserStatus.NoResponse
                                ? await _synthbotRestClient.GetUserFromDiscordIdAsync(user.Id.ToString())
                                : null;

            var playlist = await GetPlaylist(newChannel.Name);

            switch (status)
            {
            case DiscordUserStatus.New when _notificationsEnabled:
            {
                var uri = _spotifyInfoService.GetLoginUriAuto(user.Id.ToString(), user.Username);
                await user.SendMessageAsync(
                    $"Reply with \"@{_discord.CurrentUser.Username} notify\" to opt in to future notifications from me",
                    false,
                    EmbedFactory.Welcome.NewEmbed(user.Username, _discord.CurrentUser, uri));

                await _synthbotRestClient.SetDiscordUserStatus(user.Id.ToString(), DiscordUserStatus.NoResponse);

                return;
            }

            case DiscordUserStatus.RegisteredWithNotify when(synthbotUser?.AutoJoin ?? false):
            {
                await _synthbotRestClient.AddUserToChannel(newChannel.Name);

                if (_notificationsEnabled)
                {
                    await user.SendMessageAsync("", false, EmbedFactory.Notifications.AutoJoinNotify(_discord.CurrentUser, newChannel, playlist));
                }
                return;
            }

            case DiscordUserStatus.RegisteredWithNotify when(!synthbotUser?.AutoJoin ?? false) && _notificationsEnabled:
                await user.SendMessageAsync("", false, EmbedFactory.Notifications.Notify(_discord.CurrentUser, newChannel, playlist));

                break;

            case DiscordUserStatus.RegisteredWithoutNotify when synthbotUser?.AutoJoin ?? false:
                await _synthbotRestClient.AddUserToChannel(newChannel.Name);

                return;

            case DiscordUserStatus.RegisteredWithoutNotify:
            case DiscordUserStatus.NoResponse:
                return;

            default:
                throw new ArgumentOutOfRangeException(nameof(status), status, null);
            }
        }