protected override async Task _Invoke(MessageContext context) { var channelId = context.MessageEvent.Channel.Id; if (!EphemeralData.ContainsId(channelId)) { await context.Reply("This channel is already non-ephemeral").ConfigureAwait(false); return; } var messageId = context.MessageEvent.Message.Id; DiscordMessage reply; if (EphemeralData.Remove(channelId)) { reply = await context.Reply("This channel is no longer ephemeral.").ConfigureAwait(false); } else { reply = await context.Reply(":x: Error: could not mark this channel as non-ephemeral.").ConfigureAwait(false); } EphemeralContext.NoDeleteMessageIdSet.Add(messageId); EphemeralContext.NoDeleteMessageIdSet.Add(reply.Id); }
protected override async Task _Invoke(MessageContext context) { var args = context.GetSequentialArgs(Triggers.Length); int deleteDelay = (args.Length > 0 && int.TryParse(args[0], out deleteDelay)) ? deleteDelay : DefaultDeleteDelay; var messageId = context.MessageEvent.Message.Id; DiscordMessage reply; var channelId = context.MessageEvent.Channel.Id; var wasEphemeral = EphemeralData.ContainsId(channelId); if (EphemeralData.Put(channelId, deleteDelay)) { if (wasEphemeral) { reply = await context.Reply($"Updated this channel's ephemeral delay, now {deleteDelay} seconds.").ConfigureAwait(false); } else { reply = await context.Reply($"This channel is now ephemeral, delay is {deleteDelay} seconds.").ConfigureAwait(false); } } else { if (wasEphemeral) { reply = await context.Reply(":x: Error: could not update this channel's ephemeral delay.").ConfigureAwait(false); } else { reply = await context.Reply(":x: Error: could not mark this channel as ephemeral.").ConfigureAwait(false); } } EphemeralContext.NoDeleteMessageIdSet.Add(messageId); EphemeralContext.NoDeleteMessageIdSet.Add(reply.Id); }
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 bool IsTriggeredByMessage(MessageContext context) { return(EphemeralData.ContainsId(context.MessageEvent.Channel.Id)); }