Add guild name to database on join.
This commit is contained in:
@@ -8,7 +8,7 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
from utilities.sql_data_classes import Guild, engine
|
from utilities.sql_data_classes import Guild, engine
|
||||||
from utilities.utils import add_preset_configuration
|
from utilities.utils import add_preset_configuration # TODO
|
||||||
|
|
||||||
|
|
||||||
class GuildListener(commands.Cog, name="Guild Listener"):
|
class GuildListener(commands.Cog, name="Guild Listener"):
|
||||||
@@ -21,7 +21,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
|||||||
async def on_guild_join(self, guild: nextcord.Guild):
|
async def on_guild_join(self, guild: nextcord.Guild):
|
||||||
"""Listener for Guild Join. Adds guild to database."""
|
"""Listener for Guild Join. Adds guild to database."""
|
||||||
|
|
||||||
new_guild = Guild(GuildId=guild.id)
|
new_guild = Guild(GuildId=guild.id, GuildName=guild.name)
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
session.add(new_guild)
|
session.add(new_guild)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use highscores;
|
|||||||
|
|
||||||
CREATE TABLE Guilds(
|
CREATE TABLE Guilds(
|
||||||
GuildId bigint unsigned not null unique,
|
GuildId bigint unsigned not null unique,
|
||||||
|
GuildName varchar(95) not null,
|
||||||
SubmissionChannel bigint unsigned,
|
SubmissionChannel bigint unsigned,
|
||||||
VerificationChannel bigint unsigned,
|
VerificationChannel bigint unsigned,
|
||||||
PRIMARY KEY (GuildId)
|
PRIMARY KEY (GuildId)
|
||||||
|
|||||||
Reference in New Issue
Block a user