Skip to content

Commit

Permalink
Add new !join query.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ammon Smith committed Jul 14, 2019
1 parent 21f235c commit 0d0002c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions suspicious-users/join-command.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Looks for people who send '!join' right after joining,
-- and then deleted it soon after.

-- Uses snowflake_time from id_to_snowflake.sql

SELECT
users.name || '#' || users.discriminator AS username,
snowflake_time(users.real_user_id) AS created_at,
messages.created_at AS message_sent,
messages.deleted_at AS message_deleted,
users.real_user_id,
users.int_user_id
FROM messages
JOIN users
ON messages.int_user_id = users.int_user_id
WHERE messages.content = '!join'
AND messages.channel_id = 209074609893408768 -- #join
AND messages.deleted_at IS NOT NULL
AND messages.deleted_at - messages.created_at < '4 minutes'::interval;
4 changes: 2 additions & 2 deletions suspicious-users/join-date.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-- Looks for suspicious new joins.
-- Specifically looks at people who made their account soon before joining,
-- Looks for people who made their account soon before joining,
-- and do not have the 'Member' role.

-- Uses snowflake_time from id_to_snowflake.sql
Expand All @@ -22,6 +21,7 @@ LEFT JOIN (
ON guild_membership.int_user_id = members.int_user_id
AND guild_membership.guild_id = members.guild_id
WHERE joined_at - snowflake_time(users.real_user_id) < '30 days'::interval
AND guild_membership.guild_id = 181866934353133570 -- Programming
AND guild_membership.joined_at > '2019-06-22 07:22:29'::timestamp -- CHANGE ME
AND guild_membership.is_member = true
ORDER BY joined_at, created_at;

0 comments on commit 0d0002c

Please sign in to comment.