コード例 #1
0
        public async Task DeleteAllMessages
        (
            [Summary("The channel on which the the messages to delete are contained.")]
            ITextChannel textChannel
        )
        {
            if (textChannel is not IGuildChannel guildChannel || guildChannel.GuildId != Context.Guild.Id)
            {
                await Context.Channel.SendMessageAsync("This server does not contain the provided channel.");

                return;
            }

            var firstMessageID = (await textChannel.GetFirstMessageAsync())?.Id ?? 0;
            var lastMessageID  = (await textChannel.GetLastMessageAsync())?.Id ?? 0;

            if (firstMessageID == 0 || lastMessageID == 0)
            {
                await Context.Channel.SendMessageAsync("The channel contains no messages.");

                return;
            }

            await DeleteOtherChannelMessages(textChannel, firstMessageID, lastMessageID);
        }
コード例 #2
0
        public async Task DeleteOtherChannelMessages
        (
            [Summary("The channel on which the the messages to delete are contained.")]
            ITextChannel textChannel,
            [Summary("The ID of the first message that will be deleted, **inclusive**.")]
            ulong firstMessageID
        )
        {
            var lastMessageID = (await textChannel.GetLastMessageAsync()).Id;

            await DeleteOtherChannelMessages(textChannel, firstMessageID, lastMessageID);
        }