コード例 #1
0
        public static async Task NotifyStrike(DiscordUser victim, DiscordUser striker, DiscordUserDataStrike strike, DiscordGuild guild, DiscordUserData data)
        {
            //Notify a user that they've been struck
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();

            builder.Title       = "You have been struck in " + guild.Name + "!";
            builder.Description = $"{striker.Username}#{striker.Discriminator} struck you. You now have {data.GetActiveStrikes().Length} strikes. When you hit {Program.config.ban_strikes} strikes, you will be **banned** from {guild.Name}.";
            if (strike.expire_time.HasValue)
            {
                builder.AddField("Expires", BotTools.DateTimeToString(strike.GetExpiry().Value));
            }
            else
            {
                builder.AddField("Expires", "*Never*");
            }
            builder.AddField("Striked By", $"{striker.Username}#{striker.Discriminator}");
            builder.AddField("Added", BotTools.DateTimeToString(strike.GetTime()));
            builder.AddField("Message", strike.message);
            builder.Color  = DiscordColor.Yellow;
            builder.Footer = new DiscordEmbedBuilder.EmbedFooter
            {
                Text = Program.FOOTER_TEXT
            };
            await BotTools.SendMemberMsg(victim.Id, builder.Build());
        }
コード例 #2
0
        public static async Task OnBannedMemberJoined(DiscordUserData data, DiscordGuild server, DiscordMember member)
        {
            //Gather data
            DiscordUserDataStatusBanned status = data.temp_banned;

            //Send them a message telling them why they were banned, if they have any strikes, ect.
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();

            builder.Title = "You are banned temporarily from " + server.Name + ".";
            if (status.is_automated)
            {
                builder.Description = "You cannot join this server. You were banned for having too many strikes. Your active strikes are listed below.";
                var strikes = data.GetActiveStrikes();
                for (int i = 0; i < strikes.Length; i += 1)
                {
                    DiscordUserDataStrike strike = strikes[i];
                    string message = $"*Added {BotTools.DateTimeToString(strike.GetTime())}*\n";
                    if (strike.expire_time.HasValue)
                    {
                        message += $"*__Expires {BotTools.DateTimeToString(strike.GetExpiry().Value)}__*\n";
                    }
                    else
                    {
                        message += "*__Never expires__*\n";
                    }
                    builder.AddField($"Strike {i+1} from {await BotTools.GetRemoteUsername(strike.striker)}", message + strike.message);
                }
            }
            else
            {
                DiscordUser user = await Program.discord.GetUserAsync(status.catalyst);

                builder.Description = $"You cannot join this server. You were banned by a member.";
                builder.AddField("Banned By", $"{user.Username}#{user.Discriminator}");
                builder.AddField("Reason", status.reason);
            }
            builder.AddField("Expires", $"This ban expires on {BotTools.DateTimeToString((DateTime)status.GetExpiry())}. You may rejoin after this time.");
            builder.AddField("Expires In", BotTools.DateTimeOffsetToString((DateTime)status.GetExpiry() - DateTime.UtcNow));
            builder.AddField("Added", $"You were banned on {BotTools.DateTimeToString(status.GetAppliedSince())}");
            builder.Color  = DiscordColor.Red;
            builder.Footer = new DiscordEmbedBuilder.EmbedFooter
            {
                Text = Program.FOOTER_TEXT
            };
            DiscordEmbed embed = builder.Build();

            //DM this to the person
            await BotTools.SendMemberMsg(member.Id, embed);

            //Kick them from this server
            await server.RemoveMemberAsync(member, "Automated temp ban system.");
        }