@commands.Cog.listener()
async def on_guild_join(self, guild):
cli = self.client
ctx = cli.get_context
await ctx.create_text_channel("announcements-and-suggestions")
await ctx.create_text_channel("log")
general = find(lambda x: x.name == 'announcements-and-suggestions', guild.text_channels)
if general and general.permissions_for(guild.me).send_messages:
await ctx.send(f"Hello {guild.name}! I am {self.client.user.display_name}. Thank you for inviting me.\n\nTo see what commands I have available type `r?help`.\nIf you want to see my available AutoResponse Triggers type `gethelp`.")
import pymysql
from pymysql.constants import CLIENT
conn = {
"host": "mysql_server_hostname",
"password": "my_password",
"port": <<port_no>>,
"user": "my_username",
"client_flag": CLIENT.MULTI_STATEMENTS
}
x = '\n'.join(open('file.sql', 'r').readlines())
with pymysql.connect(**conn) as cur:
cur.execute(x)