async def ListenThisChannel(message): db.custom_insert(f"""UPDATE ServerConfigs SET listen_channels = '{{"{message.channel.id}"}}' WHERE id={message.guild.id}""" ) await message.channel.send( "A partir de agora receberei comandos exclusivamente neste canal")
async def ListenChannel(message): db.custom_insert(f"""UPDATE ServerConfigs SET listen_channels = array_cat(listen_channels,'{{ {message.channel.id} }}') WHERE id={message.guild.id}""") await message.channel.send( "A partir de agora receberei comandos neste canal")
async def IgnoreChannel(message): db.custom_insert(f"""UPDATE ServerConfigs SET listen_channels = array_remove(listen_channels,'{message.channel.id}') WHERE id={message.guild.id}""") await message.channel.send( "A partir de agora ignorarei comandos neste canal")
async def UnsetAutorole(message): db.custom_insert(f"""UPDATE ServerConfigs SET role = Null WHERE id = {message.guild.id} """) await message.channel.send( "O sistema de autorole foi desativado com sucesso")
async def UnsetWelcome(message): db.custom_insert(f"""UPDATE ServerConfigs SET welcome_channel= NULL , welcome_message= NULL WHERE id = {message.guild.id} """) await message.channel.send( "O sistema de recepção de membros foi desativado com sucesso")
def countPoints(server_id: int, user_id: int, chars: int): date = datetime.now().date() date -= timedelta(days=date.weekday()) #Limits the amount of points from one message to 100 chars = min(chars, 100) db.custom_insert(f"""INSERT INTO Rank VALUES ({user_id},{server_id},'{date}',1,{chars}) ON CONFLICT(user_id,server_id,date) DO UPDATE SET messages = Rank.messages+1,chars = Rank.chars+{chars} """)
async def SetWelcome(message): args = comms.ParseArguments(message.content) text = args["t"].split('"')[1] text = text.replace("¬", "-") db.custom_insert(f"""UPDATE ServerConfigs SET welcome_channel={message.channel.id}, welcome_message='{text}' WHERE id = {message.guild.id} """) await message.channel.send( f"""A partir de agora este é o canal de recepção,com a seguinte mensagem: `{text}`""" )
async def SetAutorole(message): args = comms.ParseArguments(message.content) role_id = int(args["r"]) role = message.guild.get_role(role_id) if (role == None): await message.channel.send("ID inválido") return role_id = int(args["r"]) db.custom_insert(f"""UPDATE ServerConfigs SET role = {role_id} WHERE id = {message.guild.id} """) await message.channel.send( f"A partir de agora todos os novos membros receberão o cargo {role.name}" )
def CountMessage(server_id: int): db.custom_insert(f"""INSERT INTO Messages VALUES ({server_id},'{datetime.now().date()}',1) ON CONFLICT(Date,Server) DO UPDATE SET Num = Messages.Num+1""")
from core.CRUD import db from psycopg2.errors import DuplicateTable try: server.CreateServerTable() rank.CreateRankTable() messages.CreateMessagesTable() except DuplicateTable: print("Tables already exists") print( "TYPE 'reset' IN ORDER TO DELETE THE OLD TABLES AND CREATE NEW ONES. BE CAREFULL, THIS WILL ERASE ALL DATA" ) if (input().lower() == 'reset'): db.custom_insert("DROP TABLE ServerConfigs") db.custom_insert("DROP TABLE Rank") db.custom_insert("DROP TABLE Messages") server.CreateServerTable() rank.CreateRankTable() messages.CreateMessagesTable() f = open("localToken.txt", "w") f.write("Remove this and paste your bot token here") f.close() f = open("immoral_chars.json", "w") f.write("""{ "𝓘" : "I", "𝓪" : "a", "𝓶": "m",