Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #setup
- connection = sqlite3.connect("data/database.db")
- cursor = connection.cursor()
- cursor.execute("CREATE TABLE IF NOT EXISTS Roles (roleid INTEGER PRIMARY KEY UNIQUE)")
- cursor.execute("CREATE TABLE IF NOT EXISTS Users (userid INTEGER PRIMARY KEY UNIQUE, roleids TEXT)")
- connection.commit()
- #verify
- @plugin.slash_command(name="verify-data", description="Verifies all data is stored correctly")
- async def verify_integ(self, inter:CommandInteraction):
- cursor.execute("SELECT * FROM Roles")
- roles = cursor.fetchall()
- cursor.execute("SELECT * FROM Users")
- users = cursor.fetchall()
- await inter.response.send_message(f"ROLES\n{roles}\n\nUSERS\n{users}")
- #member update
- @plugin.listener("on_member_update")
- async def member_update(before:Member, after:Member):
- beforef = [role.id for role in before.roles]
- afterf = [role.id for role in after.roles]
- removed_roles = set(beforef) - set(afterf)
- cursor.execute("SELECT * FROM Users WHERE ? IN (roleids)", (str(list(removed_roles)[0]),))
- users = cursor.fetchall()
- print(users)
Advertisement
Add Comment
Please, Sign In to add comment