|
|
@ -106,17 +106,13 @@ async def on_member_join(member):
|
|
|
|
# Get the guild
|
|
|
|
# Get the guild
|
|
|
|
guild = member.guild
|
|
|
|
guild = member.guild
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the guild is Enso
|
|
|
|
|
|
|
|
if guild.id != enso_guild_ID:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# Set up connection to database
|
|
|
|
# Set up connection to database
|
|
|
|
with db.connection() as conn:
|
|
|
|
with db.connection() as conn:
|
|
|
|
name = f"{member.name}#{member.discriminator}"
|
|
|
|
name = f"{member.name}#{member.discriminator}"
|
|
|
|
# Define the Insert Into Statement inserting into the database
|
|
|
|
# Define the Insert Into Statement inserting into the database
|
|
|
|
insert_query = """INSERT INTO members (discordUser, discordID) VALUES (?, ?)"""
|
|
|
|
insert_query = """INSERT INTO members (guildID, discordUser, discordID) VALUES (?, ?)"""
|
|
|
|
vals = name, member.id
|
|
|
|
vals = member.guild.id, name, member.id,
|
|
|
|
cursor = conn.cursor()
|
|
|
|
cursor = conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
# Execute the SQL Query
|
|
|
|
# Execute the SQL Query
|
|
|
@ -127,6 +123,10 @@ async def on_member_join(member):
|
|
|
|
except mariadb.Error as ex:
|
|
|
|
except mariadb.Error as ex:
|
|
|
|
print("Parameterized Query Failed: {}".format(ex))
|
|
|
|
print("Parameterized Query Failed: {}".format(ex))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the guild is Enso
|
|
|
|
|
|
|
|
if guild.id != enso_guild_ID:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Set the channel id to "newpeople"
|
|
|
|
# Set the channel id to "newpeople"
|
|
|
|
new_people = guild.get_channel(enso_newpeople_ID)
|
|
|
|
new_people = guild.get_channel(enso_newpeople_ID)
|
|
|
|
|
|
|
|
|
|
|
@ -164,21 +164,17 @@ async def on_member_remove(member):
|
|
|
|
# Get the guild
|
|
|
|
# Get the guild
|
|
|
|
guild = member.guild
|
|
|
|
guild = member.guild
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the guild is Enso
|
|
|
|
|
|
|
|
if guild.id != enso_guild_ID:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
# With the database connection
|
|
|
|
# With the database connection
|
|
|
|
with db.connection() as conn:
|
|
|
|
with db.connection() as conn:
|
|
|
|
|
|
|
|
|
|
|
|
# Delete the record of the member as they leave the server
|
|
|
|
# Delete the record of the member as they leave the server
|
|
|
|
insert_query = """DELETE FROM members WHERE discordID = (?)"""
|
|
|
|
delete_query = """DELETE FROM members WHERE discordID = (?) AND guildID = (?)"""
|
|
|
|
val = member.id,
|
|
|
|
vals = member.id, guild.id
|
|
|
|
cursor = conn.cursor()
|
|
|
|
cursor = conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
# Execute the SQL Query
|
|
|
|
# Execute the SQL Query
|
|
|
|
cursor.execute(insert_query, val)
|
|
|
|
cursor.execute(delete_query, vals)
|
|
|
|
conn.commit()
|
|
|
|
conn.commit()
|
|
|
|
print(cursor.rowcount, "Record deleted successfully from Members")
|
|
|
|
print(cursor.rowcount, "Record deleted successfully from Members")
|
|
|
|
|
|
|
|
|
|
|
|