Beispiel #1
0
        private async Task <ITextChannel> GetChannel(DeleteMessageTimerArgs deleteArgs)
        {
            IChannel channel = await _client.GetChannelAsync(deleteArgs.ChannelId);

            ITextChannel textChannel = channel as ITextChannel;

            return(textChannel);
        }
Beispiel #2
0
        private static async Task DeleteMessage(DeleteMessageTimerArgs deleteArgs, ITextChannel textChannel)
        {
            IMessage message = await textChannel.GetMessageAsync(deleteArgs.MessageId);

            if (message != null)
            {
                await textChannel.DeleteMessagesAsync(new[] { message });
            }
        }
Beispiel #3
0
        private void OnTimedEvent(object state)
        {
            DeleteMessageTimerArgs deleteArgs = (state as DeleteMessageTimerArgs);

            if (deleteArgs != null)
            {
                Task.Run(async() =>
                {
                    var textChannel = await GetChannel(deleteArgs);
                    if (textChannel != null)
                    {
                        await DeleteMessage(deleteArgs, textChannel);
                    }
                });
            }
            OnTimerHandeld(this);
            Dispose();
        }