예제 #1
0
        public async Task <bool> EnsureCorrectTextChat(ICommandContext context)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var result        = false;
            var configuration = await _configurationRepository.GetConfiguration <PlayerConfiguration>(context.Guild.Id, "PlayerViewConfiguration");


            if (configuration?.TextChatId == context.Channel.Id)
            {
                result = true;
            }
            else
            {
                if (configuration is null)
                {
                    var embed = new EmbedBuilder
                    {
                        Description = "Player musi być najpierw zainstalowany przez administracje `!setup <nazwa chatu tekstowego do obsługi bota>`, musi też posiadać uprawnienie do usuwania wiadomości"
                    }.Build();
                    var resp = await context.Channel.SendMessageAsync(embed : embed);

                    await _messageRemoverService.SaveBotResponse(context, resp);
                }
                else
                {
                    var channel = (IMessageChannel)_discordSocketClient.GetChannel(configuration.TextChatId);

                    var embed = new EmbedBuilder
                    {
                        Description = $"Usługa odtwarzania muzyki jest obsługiwana tylko na kanale #{channel.Name}"
                    }.Build();
                    var resp = await context.Channel.SendMessageAsync(embed : embed);

                    await _messageRemoverService.SaveBotResponse(context, resp);
                }
            }

            return(result);
        }
예제 #2
0
        public async Task ReplyImage(string description = null, string url = null)
        {
            var embed = new EmbedBuilder
            {
                ImageUrl    = url,
                Description = description
            };

            var response = await ReplyAsync(embed : embed.Build());

            await _responseRemover.SaveBotResponse(Context, response);
        }
예제 #3
0
        public async Task <IUserMessage> SendErrorAsync(CommandContext context, IResult result)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var response = await context.Channel.SendMessageAsync(result?.ErrorReason);

            await _responseRemover.SaveBotResponse(context, response);

            return(response);
        }