Esempio n. 1
0
            public override Task Run(ref IReminder?_)
            {
                Console.WriteLine("Send reminder " + _reminder.ID);

                return(Task.Run(async() =>
                {
                    if (_client.GetChannel(_reminder.ChannelId) is ITextChannel channel)
                    {
                        if (!string.IsNullOrWhiteSpace(_reminder.Prelude))
                        {
                            await channel.SendMessageAsync(_reminder.Prelude);
                        }

                        string name = await Name(_reminder.UserId, channel.Guild);

                        var embed = new EmbedBuilder()
                                    .WithDescription(_reminder.Message)
                                    .WithAuthor(name)
                                    .WithFooter(new BalderHash32(_reminder.ID).ToString());

                        await channel.SendMessageAsync(embed: embed.Build());
                    }
                    else
                    {
                        Console.WriteLine($"Cannot send reminder: Channel `{_reminder.ChannelId}` is null");
                    }

                    await _reminders.Delete(_reminder.UserId, _reminder.ID);
                }));
            }
Esempio n. 2
0
        public async Task CancelReminder([NotNull] string id)
        {
            var parsed = FriendlyId32.Parse(id);

            if (!parsed.HasValue)
            {
                await TypingReplyAsync("Invalid ID");

                return;
            }

            if (await _reminders.Delete(parsed.Value.Value))
            {
                await TypingReplyAsync($"Deleted reminder `{id}`");
            }
            else
            {
                await TypingReplyAsync($"I can't find a reminder with id `{id}`");
            }
        }
Esempio n. 3
0
        public async Task CancelReminder(string id)
        {
            var parsed = BalderHash32.Parse(id);

            if (!parsed.HasValue)
            {
                await TypingReplyAsync("Invalid ID");

                return;
            }

            if (await _reminders.Delete(Context.User.Id, parsed.Value.Value))
            {
                await TypingReplyAsync($"Deleted reminder `{id}`");
            }
            else
            {
                await TypingReplyAsync($"I can't find a reminder with id `{id}`");
            }
        }
Esempio n. 4
0
            public override Task Run(ref IReminder _)
            {
                Console.WriteLine("Send reminder " + _reminder.ID);

                return(Task.Run(async() =>
                {
                    if (_client.GetChannel(_reminder.ChannelId) is ITextChannel channel)
                    {
                        if (!string.IsNullOrWhiteSpace(_reminder.Prelude))
                        {
                            await channel.SendMessageAsync(_reminder.Prelude);
                        }

                        string name;
                        if (channel.Guild != null)
                        {
                            var user = (await channel.Guild.GetUserAsync(_reminder.UserId));
                            name = user.Nickname ?? user.Username;
                        }
                        else
                        {
                            var user = _client.GetUser(_reminder.UserId);
                            name = user.Username;
                        }

                        var embed = new EmbedBuilder()
                                    .WithDescription(_reminder.Message)
                                    .WithAuthor(name)
                                    .WithFooter(new FriendlyId32(_reminder.ID).ToString());

                        await channel.SendMessageAsync(embed: embed.Build());
                    }
                    else
                    {
                        Console.WriteLine($"Cannot send reminder: Channel `{_reminder.ChannelId}` is null");
                    }

                    await _reminders.Delete(_reminder.ID);
                }));
            }