private async Task SendNotification(TimerItem timer, ulong channel)
        {
            try
            {
                var remains = timer.GetRemains();
                var stage   = timer.GetStageName();
                var mode    = timer.GetModeName();
                var embed   = new EmbedBuilder()
                              .WithTitle(LM.Get("timerNotifyTitle", string.IsNullOrEmpty(timer.timerLocation) ? "-" : timer.timerLocation))
                              .AddField(LM.Get("timersType"), string.IsNullOrEmpty(mode) ? "-" : mode, true)
                              .AddField(LM.Get("timersStage"), string.IsNullOrEmpty(stage) ? "-" : stage, true)
                              .AddField(LM.Get("timersOwner"), string.IsNullOrEmpty(timer.timerOwner) ? "-" : timer.timerOwner, true)
                              .AddField(LM.Get("timersRemaining"), string.IsNullOrEmpty(remains) ? "-" : remains, true)
                              .AddField(LM.Get("timersNotes"), string.IsNullOrEmpty(timer.timerNotes) ? "-" : timer.timerNotes);
                if (!string.IsNullOrEmpty(Settings.Resources.ImgTimerAlert))
                {
                    embed.WithThumbnailUrl(Settings.Resources.ImgTimerAlert);
                }

                var ch = APIHelper.DiscordAPI.GetChannel(channel);
                if (ch == null)
                {
                    await LogHelper.LogWarning($"Discord channel {channel} not found!", Category);
                }
                else
                {
                    await APIHelper.DiscordAPI.SendMessageAsync(ch, Settings.TimersModule.DefaultMention ?? " ", embed.Build()).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                await LogHelper.LogEx(ex.Message, ex, Category);
            }
        }
Beispiel #2
0
        private async Task SendNotification(TimerItem timer, ulong channel)
        {
            try
            {
                var remains = timer.GetRemains();
                var stage   = timer.GetStageName();
                var mode    = timer.GetModeName();
                var embed   = new EmbedBuilder()
                              .WithTitle(LM.Get("timerNotifyTitle", string.IsNullOrEmpty(timer.timerLocation) ? "-" : timer.timerLocation))
                              .AddInlineField(LM.Get("timersType"), string.IsNullOrEmpty(mode) ? "-" : mode)
                              .AddInlineField(LM.Get("timersStage"), string.IsNullOrEmpty(stage) ? "-" : stage)
                              .AddInlineField(LM.Get("timersOwner"), string.IsNullOrEmpty(timer.timerOwner) ? "-" : timer.timerOwner)
                              .AddInlineField(LM.Get("timersRemaining"), string.IsNullOrEmpty(remains) ? "-" : remains)
                              .AddField(LM.Get("timersNotes"), string.IsNullOrEmpty(timer.timerNotes) ? "-" : timer.timerNotes);
                if (!string.IsNullOrEmpty(Settings.Resources.ImgTimerAlert))
                {
                    embed.WithThumbnailUrl(Settings.Resources.ImgTimerAlert);
                }

                await APIHelper.DiscordAPI.SendMessageAsync(APIHelper.DiscordAPI.GetChannel(channel), "@everyone", embed.Build()).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await LogHelper.LogEx(ex.Message, ex, Category);
            }
        }
Beispiel #3
0
        private async Task SendNotification(TimerItem timer, ulong channel)
        {
            var embed = new EmbedBuilder()
                        .WithTitle(string.Format(LM.Get("timerNotifyTitle"), timer.timerLocation) ?? "-")
                        .WithThumbnailUrl(SettingsManager.Get("resources", "imgTimerAlert") ?? "-")
                        .AddInlineField(LM.Get("timersType"), timer.GetModeName())
                        .AddInlineField(LM.Get("timersStage"), timer.GetStageName())
                        .AddInlineField(LM.Get("timersOwner"), timer.timerOwner ?? "-")
                        .AddInlineField(LM.Get("timersRemaining"), timer.GetRemains())
                        .AddField(LM.Get("timersNotes"), timer.timerNotes ?? "-");

            await APIHelper.DiscordAPI.SendMessageAsync(APIHelper.DiscordAPI.GetChannel(channel), "@everyone", embed.Build()).ConfigureAwait(false);
        }