protected override async Task _Invoke(MessageContext context) { DiscordChannel channel = context.MessageEvent.Channel; ulong id = channel.Id; try { if (EphemeralData.ContainsId(id)) { await context.Reply($"This channel is ephemeral; delay is {EphemeralData.Get(id)} seconds.").ConfigureAwait(false); } else { await context.Reply("This channel is not ephemeral.").ConfigureAwait(false); } } catch (Exception e) { Console.WriteLine(e); throw; } }
protected override async Task _Invoke(MessageContext context) { if (_ephemeralContext.NoDeleteMessageIdSet.Contains(context.MessageEvent.Message.Id)) { _ephemeralContext.NoDeleteMessageIdSet.Remove(context.MessageEvent.Message.Id); return; } var channelId = context.MessageEvent.Channel.Id; if (EphemeralData.Get(channelId) == 0) { await context.MessageEvent.Message.DeleteAsync().ConfigureAwait(false); return; } var deleteTimer = new Timer(EphemeralData.Get(channelId) * 1000); deleteTimer.Elapsed += (sender, args) => context.MessageEvent.Message.DeleteAsync(); deleteTimer.AutoReset = false; deleteTimer.Enabled = true; }