예제 #1
0
 async def get_greetings_channel(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute("SELECT greeting_cid FROM toggles WHERE guild_id=?",
                        (guild_id, ))
         output = cursor.fetchone()
         return output[0] if output != None else None
예제 #2
0
 def __init__(self):
     with sqlconnect(os.path.join(bot_path, 'databases', 'conquest.db')) as cursor:
         cursor.execute("CREATE TABLE IF NOT EXISTS conquest(settlement_id INTEGER PRIMARY KEY ,invite_string BLOB,\
                 date_created BLOB,founderid BLOB,leaderid BLOB,name BLOB,treasury INTEGER,tech_attack INTEGER,\
                 tech_defence INTEGER, size INTEGER, tech_tree BLOB,\
                 type INTEGER,entry_fee INTEGER, wins INTEGER, losses INTEGER, experience INTEGER)")
         cursor.execute("CREATE TABLE IF NOT EXISTS members(userid INTEGER PRIMARY KEY, settlement_id INTEGER)")
         cursor.execute("CREATE TABLE IF NOT EXISTS resources(settlement_id INTEGER PRIMARY KEY, cloth INTEGER, wood INTEGER, stone INTEGER, food INTEGER)")
         cursor.execute("CREATE TABLE IF NOT EXISTS buildings(id INTEGER PRIMARY KEY, name BLOB, mltplr_cloth INTEGER, mltplr_food INTEGER, mltplr_stone INTEGER, mltplr_wood INTEGER, mltplr_gold INTEGER)")
         # Inserting buildings
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (1, 'Town Hall', 0, 1, 1, 1, 250,))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (2, 'Training Grounds', 5, 5, 2, 2, 0,))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (3, 'Market Square', 0, 0, 0, 0, 2500,))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (4, 'Walls', 0, 0, 5, 5, 50,))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (5, 'Quarry', 3, 3, 0, 0, 20))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (6, 'Farms', 0, 0, 0, 7, 20))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (7, 'Weavery', 0, 7, 0, 0, 5))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (8, "Lumberjack's Camp", 2, 7, 0, 0, 5))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (9, 'Warehouse', 0, 0, 0, 0, 5000))
         cursor.execute("INSERT OR IGNORE INTO buildings(id, name, mltplr_cloth, mltplr_food, mltplr_stone, mltplr_wood, mltplr_gold) VALUES(?, ?, ?, ?, ?, ?, ?)",
                        (10, 'Academy', 0, 0, 5, 5, 125))
예제 #3
0
 async def get(self, user_id: int, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "INSERT OR IGNORE INTO profiles (user_id, guild_id) VALUES(?, ?)",
             (
                 user_id,
                 guild_id,
             ))
         cursor.execute(
             "SELECT IFNULL(experience, 0), IFNULL(level, 0), background, bio FROM profiles WHERE user_id=? AND guild_id=?",
             (
                 user_id,
                 guild_id,
             ))
         output = cursor.fetchone()
         if not output:
             return None
         else:
             output = list(output)
             return_dict = dict(experience=output[0],
                                level=output[1],
                                background=output[2],
                                bio=output[3])
             return return_dict
예제 #4
0
 async def reset_bye_msg(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute("UPDATE toggles SET bye_msg=? WHERE guild_id=?", (
             None,
             guild_id,
         ))
예제 #5
0
    async def get_settlement(self, get_string: str, input_data):
        with sqlconnect(os.path.join(bot_path, 'databases', 'conquest.db')) as cursor:
            if get_string == 'user':
                cursor.execute("SELECT * FROM conquest WHERE leaderid=?", (input_data,))
            elif get_string == 'settlement':
                cursor.execute("SELECT * FROM conquest WHERE name=?", (input_data,))
            elif get_string == 'code':
                cursor.execute("SELECT * FROM conquest WHERE invite_string=?", (input_data,))
            elif get_string == 'id':
                cursor.execute("SELECT * FROM conquest WHERE settlement_id=?", (input_data,))
            elif get_string == 'member':
                cursor.execute("SELECT c.* FROM conquest as c INNER JOIN members as m ON c.settlement_id = m.settlement_id WHERE m.userid=?", (input_data,))
            else:
                return None

            db_output = cursor.fetchone()
            if db_output is None:
                return None
            else:
                db_output = list(db_output)
                return_dict = dict(settlement_id=db_output[0], invite_string=db_output[1], date_created=db_output[2], founderid=db_output[3],
                                   leaderid=db_output[4], name=db_output[5], treasury=db_output[6], tech_attack=db_output[7],
                                   tech_defence=db_output[8], size=db_output[9], tech_tree=db_output[10], type=db_output[11],
                                   entry_fee=db_output[12], wins=db_output[13], losses=db_output[14], experience=db_output[15])
                return return_dict
예제 #6
0
 async def get_channel(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute("SELECT channel_id FROM modlog WHERE guild_id=?",
                        (guild_id, ))
         output = cursor.fetchone()
         return output[0] if output else None
예제 #7
0
 async def get_custom_goodbye(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute("SELECT bye_msg FROM toggles WHERE guild_id=?",
                        (guild_id, ))
         output = cursor.fetchone()
         return output[0] if output else None
예제 #8
0
 async def clear_action(self, user_id: int, guild_id: int,
                        action: ModerationAction):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "DELETE FROM temporary_actions WHERE user_id=? AND guild_id=? AND action=?",
             (user_id, guild_id, int(action)))
예제 #9
0
 async def start_giveaway(self, msg_id: int, value: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "INSERT OR IGNORE INTO giveaways(msgid, value) VALUES(?, ?)", (
                 msg_id,
                 value,
             ))
예제 #10
0
 async def disabled_cogs(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT cog_name FROM disabled_cogs WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchall()
         return [x[0] for x in output] if output else None
예제 #11
0
 async def user_backgrounds(self, user_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "SELECT ub.background, pb.description FROM unlocked_backgrounds as ub INNER JOIN profile_backgrounds as pb ON ub.background = pb.bg_id WHERE ub.user_id=?",
             (user_id, ))
         output = cursor.fetchall()
         return output
예제 #12
0
 async def disable_greeting(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "UPDATE toggles SET greeting_status=? WHERE guild_id=?", (
                 None,
                 guild_id,
             ))
예제 #13
0
 async def get_guild(self, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT type, channel FROM leveling_notifications WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchone()
         return output if output else None
예제 #14
0
 async def remove_role(self, guild_id: int, level: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "DELETE FROM leveling_roles WHERE guild_id=? and level=?", (
                 guild_id,
                 level,
             ))
예제 #15
0
 async def get_role_count(self, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT role_id FROM leveling_roles WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchall()
         return len(output) if output else 0
예제 #16
0
 async def get_all_roles(self, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT level, role_id FROM leveling_roles WHERE guild_id=? ORDER BY level ASC",
             (guild_id, ))
         output = cursor.fetchall()
         return output
예제 #17
0
 def is_disabled(self, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT guild_id FROM disabled_leveling WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchone()
         return True if output else False
예제 #18
0
 async def leaderboard(self, guild_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "SELECT user_id, DENSE_RANK() OVER (ORDER BY level DESC, experience DESC) as rank, IFNULL(level, 0), IFNULL(experience, 0) FROM profiles WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchall()
         return output
예제 #19
0
 async def unlocked_backgrounds(self, user_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "SELECT background FROM unlocked_backgrounds WHERE user_id=?",
             (user_id, ))
         output = cursor.fetchall()
         return [x[0] for x in output] if output else None
예제 #20
0
 async def get_actions(self, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT auto_mute, auto_kick, auto_ban FROM autoactions WHERE guild_id=?",
             (guild_id, ))
         output = cursor.fetchone()
         return output
예제 #21
0
 async def end_giveaway(self, msg_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute("DELETE FROM giveaway_participants WHERE msgid=?",
                        (msg_id, ))
         cursor.execute("DELETE FROM giveaways WHERE msgid=?", (msg_id, ))
         result = cursor.rowcount
         return True if result > 0 else False
예제 #22
0
async def user_set(user_id: int, dict_input):
    with sqlconnect(os.path.join(bot_path, 'databases', 'users.db')) as cursor:
        cursor.execute(
            "INSERT OR IGNORE INTO users(userid, currency) VALUES(?, ?)",
            (user_id, '0'))
        cursor.execute(
            "UPDATE users SET currency=?, daily_time=? WHERE userid=?",
            (dict_input['currency'], dict_input['daily_time'], user_id))
예제 #23
0
 def is_banned(self, user_id: int, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "SELECT user_id FROM temporary_actions WHERE user_id=? AND guild_id=? AND action=?",
             (user_id, guild_id, int(ModerationAction.Ban)))
         output = cursor.fetchone()
         return True if output else False
예제 #24
0
 async def reset_warnings(self, guild_id: int, user_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "DELETE FROM warnings WHERE guild_id=? AND user_id=?", (
                 guild_id,
                 user_id,
             ))
예제 #25
0
 async def set_action(self, user_id: int, guild_id: int,
                      action: ModerationAction, expires: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "INSERT OR IGNORE INTO temporary_actions (user_id, guild_id, expires, action) VALUES(?, ?, ?, ?)",
             (user_id, guild_id, expires, int(action)))
         return True if cursor.rowcount > 0 else False
예제 #26
0
 async def update_user(self, user_id: int, user_data: dict):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "UPDATE voting SET combo=?, last_voted=? WHERE user_id=?", (
                 user_data['combo'],
                 user_data['last_voted'],
                 user_id,
             ))
예제 #27
0
 async def enter_giveaway(self, user_id: int, msg_id: int):
     with sqlconnect(os.path.join(main.bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "INSERT OR IGNORE INTO giveaway_participants(userid, msgid) VALUES(?, ?)",
             (
                 user_id,
                 msg_id,
             ))
예제 #28
0
 async def set_channel(self, guild_id: int, channel_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "INSERT OR REPLACE INTO modlog(guild_id, channel_id) VALUES(?, ?)",
             (
                 guild_id,
                 channel_id,
             ))
예제 #29
0
 async def set_mute_role(self, guild_id: int, role_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'servers.db')) as cursor:
         cursor.execute(
             "INSERT OR REPLACE INTO mute_roles(guild_id, mute_role) VALUES(?, ?)",
             (
                 guild_id,
                 role_id,
             ))
예제 #30
0
 async def remove_blacklist(self, user_id: int, guild_id: int):
     with sqlconnect(os.path.join(bot_path, 'databases',
                                  'users.db')) as cursor:
         cursor.execute(
             "DELETE FROM blacklisted_users WHERE user_id=? AND guild_id=?",
             (
                 user_id,
                 guild_id,
             ))