示例#1
0
        public async Task CloseThread(SocketMessage message, ISocketMessageChannel channel, SocketUser moderatorUser, string note)
        {
            var                  closedthread = CloseThreadInDb(channel);
            var                  bot          = Global.Bot;
            var                  guild        = bot.GetGuild(Global.ServerID);
            SocketGuildUser      userObj      = guild.GetUser(closedthread.UserId);
            List <ThreadMessage> messagesToLog;

            using (var db = new Database())
            {
                messagesToLog = db.ThreadMessages.Where(ch => ch.ChannelId == closedthread.ChannelId).ToList();
            }
            var modMailLogChannel = guild.GetTextChannel(Global.Channels["modmaillog"]);

            await LogClosingHeader(closedthread, messagesToLog.Count(), note, modMailLogChannel, userObj);

            await LogModMailThreadMessagesToModmailLog(closedthread, note, messagesToLog, modMailLogChannel);

            await(channel as SocketTextChannel).DeleteAsync();
            // only send the user a dm, in case the user initiated, if we use contact it should not happen
            if (userObj != null && messagesToLog.Count() > 0)
            {
                await userObj.SendMessageAsync(embed : ModMailEmbedHandler.GetClosingEmbed());
            }
        }
示例#2
0
        /// <summary>
        /// Calls the methods for closing the thread in the db and logging the modmail thread.
        /// Also sends a message to the user, in case there were interactions
        /// </summary>
        /// <param name="channel">The <see cref"Discord.WebSocket.ISocketMessageChannel"/> object of the channel which is getting closed</param>
        /// <param name="note">The optional note which is used when closing the thread</param>
        /// <returns>Task</returns>
        public async Task CloseThread(ISocketMessageChannel channel, string note)
        {
            var closedThread       = CloseThreadInDb(channel);
            int messagesToLogCount = await DeleteChannelAndLogThread(closedThread, channel, note);

            var             bot     = Global.Bot;
            var             guild   = bot.GetGuild(Global.ServerID);
            SocketGuildUser userObj = guild.GetUser(closedThread.UserId);

            // only send the user a dm, in case the user initiated, if we use contact it should not happen
            if (userObj != null && messagesToLogCount > 0)
            {
                await userObj.SendMessageAsync(embed : ModMailEmbedHandler.GetClosingEmbed());
            }
        }