Skip to content

Commit

Permalink
update per-server features
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Nov 24, 2023
1 parent 3eeea2f commit 2cfc2fa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions PerServerFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,35 @@ public class Checks
{
public static async Task MessageCreateChecks(MessageCreateEventArgs e)
{
if (e.Guild.Id == 1096948488014659728)
{
// Get member object to fetch roles
var member = await e.Guild.GetMemberAsync(e.Author.Id);
// Check roles, only continue if member does not have either of two specific roles
if (member.Roles.All(role => role.Id != 1099413365090156655 && role.Id != 1099421482783871107))
{
// Regex to match mentions
var mentionRegex = new Regex(@"(.*)?<@!?([0-9]+)>(.*)");

// Check msg content against regex
if (mentionRegex.IsMatch(e.Message.Content))
{
// Get msg before current
var msgBefore = (await e.Channel.GetMessagesBeforeAsync(e.Message.Id, 1))[0];

// If msg before also matches pattern, is from same member, has no other content aside from match, and was sent within 30 seconds, time out & warn
if (mentionRegex.IsMatch(msgBefore.Content) && msgBefore.Author.Id == e.Author.Id &&
msgBefore.CreationTimestamp.AddSeconds(30) > e.Message.CreationTimestamp &&
(((mentionRegex.Matches(msgBefore.Content)[0].Groups[3].Value == string.Empty) && mentionRegex.Matches(e.Message.Content)[0].Groups[3].Value == string.Empty &&
(mentionRegex.Matches(msgBefore.Content)[0].Groups[1].Value == string.Empty) && (mentionRegex.Matches(e.Message.Content)[0].Groups[1].Value == string.Empty))))
{
await member.ModifyAsync(member => member.CommunicationDisabledUntil = (DateTimeOffset)DateTime.Now.AddMinutes(5));
await e.Message.RespondAsync("no mass pings :3");
}
}
}
}

if (!e.Channel.IsPrivate && e.Guild.Id == 984903591816990730 && e.Message.Content.StartsWith("ch!"))
{
var message = new DiscordMessageBuilder()
Expand Down

0 comments on commit 2cfc2fa

Please sign in to comment.