Beispiel #1
0
        public async Task ReportAsync([Remainder] string output = "")
        {
            if (Context.Guild != null)
            {
                _ = WarnOfPublicReport();
            }
            var responseMessage = await Context.Channel.SendMessageAsync(Properties.Resources.ModmailThankYou);

            var guild = Context.Client.GetGuild(SpecialGuilds.CrystalExploratoryMissions);

            var member = guild.GetUser(Context.User.Id);

            var guildConfig = Db.Guilds.Single(g => g.Id == guild.Id);

            var postChannel = guild.GetTextChannel(guildConfig.ReportChannel);
            var threadStart = await postChannel.SendMessageAsync($"{Context.User.Mention} just sent a modmail!");

            var            threadName = member?.Nickname ?? Context.User.Username;
            IThreadChannel thread     =
                postChannel.Threads.FirstOrDefault(t => t.Name == threadName)
                ?? await postChannel.CreateThreadAsync(threadName, message : threadStart);

            await thread.SendMessageAsync($"<@&{guildConfig.Roles["Moderator"]}>");

            while (output.Length > 2000)
            {
                await thread.SendMessageAsync(output[..2000]);
Beispiel #2
0
        public static async Task Handler(IDbService db, SocketMessageComponent component)
        {
            if (component.Data.CustomId != "cem-modmail")
            {
                return;
            }
            if (component.Message.Channel is not ITextChannel channel)
            {
                return;
            }

            var guildConfig = db.Guilds.FirstOrDefault(g => g.Id == channel.GuildId);

            if (guildConfig == null)
            {
                Log.Warning("Modmail: no guild configuration exists for guild {GuildName}", channel.Guild.Name);
                return;
            }

            // Create the user thread
            var member = await channel.Guild.GetUserAsync(component.User.Id);

            var threadName = string.IsNullOrEmpty(member.Nickname) ? member.ToString() : member.Nickname;
            var userThread = await channel.CreateThreadAsync(threadName, ThreadType.PrivateThread);

            var requestMessage = await userThread.SendMessageAsync("Please enter the contents of your modmail here.");

            await userThread.AddUserAsync(member);

            Log.Information("Created thread \"{ThreadName}\" for user \"{User}\".", threadName, member.ToString());

            // Create the mod thread
            if (await channel.Guild.GetTextChannelAsync(guildConfig.ReportChannel) is not SocketTextChannel reportsChannel)
            {
                Log.Warning("Modmail: reports channel is not of type SocketTextChannel");
                return;
            }

            var threadStart = await reportsChannel.SendMessageAsync($"{member.Mention} just sent a modmail!");

            IThreadChannel modThread =
                reportsChannel.Threads.FirstOrDefault(t => t.Name == threadName)
                ?? await reportsChannel.CreateThreadAsync(threadName, message : threadStart);

            await modThread.SendMessageAsync($"<@&{guildConfig.Roles["Moderator"]}>: {requestMessage.GetJumpUrl()}");
        }