Compare commits
2
Commits
f43dccb12d
...
9550d1a68b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9550d1a68b | ||
|
|
b04819aa36 |
@@ -5,7 +5,6 @@ from nextcord.ext import commands
|
||||
from sqlalchemy import distinct, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Category, CategoryGroup, Score, engine
|
||||
from utilities.utils import (
|
||||
autofill_categories,
|
||||
|
||||
@@ -7,7 +7,6 @@ from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import CategoryGroup, engine
|
||||
from utilities.utils import autofill_groups, send_highscore_message
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import CategoryGroup, Guild, engine
|
||||
from utilities.utils import MAX_LINE_LENGTH, autofill_groups
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Guild, engine
|
||||
from utilities.utils import autofill_users_in_guild
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Category, CategoryGroup, Score, engine
|
||||
from utilities.utils import MAX_LINE_LENGTH, autofill_categories, autofill_groups, format_score_string
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import nextcord
|
||||
from sqlalchemy import delete, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Category, CategoryGroup, engine
|
||||
from utilities.utils import send_highscore_message
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import nextcord
|
||||
from sqlalchemy import distinct, exc, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Category, CategoryGroup, Score, engine
|
||||
from utilities.utils import send_highscore_message
|
||||
|
||||
@@ -19,7 +18,7 @@ class UpdateUsernameVerifyView(nextcord.ui.View):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-username-update")
|
||||
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): # pylint: disable=unused-argument
|
||||
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Button for denying username update. Deletes message.
|
||||
|
||||
@@ -30,7 +29,7 @@ class UpdateUsernameVerifyView(nextcord.ui.View):
|
||||
await interaction.message.delete()
|
||||
|
||||
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-username-update")
|
||||
async def approve_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): # pylint: disable=unused-argument
|
||||
async def approve_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Button for approving username update. Tells guild data to update username, then updates
|
||||
message to show it is complete.
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"""
|
||||
Defines cog for guild listeners. Contains functions for various guild events.
|
||||
"""
|
||||
"""Defines cog for guild listeners. Contains functions for various guild events."""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlmodel import col
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import Guild, engine
|
||||
from database.db import engine
|
||||
from database.models import Guild
|
||||
|
||||
|
||||
class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
@@ -18,7 +17,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_join(self, guild: nextcord.Guild):
|
||||
async def on_guild_join(self, guild: nextcord.Guild) -> None:
|
||||
"""
|
||||
Listener for Guild Join. Adds guild to database.
|
||||
|
||||
@@ -26,12 +25,12 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
guild (nextcord.Guild): Guild that was joined.
|
||||
"""
|
||||
with Session(engine) as session:
|
||||
stmt = select(Guild).where(Guild.GuildId == guild.id)
|
||||
stmt = select(Guild).where(col(Guild.id == guild.id))
|
||||
guild_data = session.scalar(stmt)
|
||||
|
||||
# just in case check if the guild already exists
|
||||
if guild_data is None:
|
||||
new_guild = Guild(GuildId=guild.id, GuildName=guild.name)
|
||||
new_guild = Guild(id=guild.id, name=guild.name)
|
||||
session.add(new_guild)
|
||||
else:
|
||||
guild_data.GuildName = guild.name
|
||||
@@ -45,7 +44,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
await imcompiling.send(f'Agon has joined server "{guild.name}"!')
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_remove(self, guild: nextcord.Guild):
|
||||
async def on_guild_remove(self, guild: nextcord.Guild) -> None:
|
||||
"""
|
||||
Listens to when the bot has been removed from a guild. Update's the database to record the active flag as false.
|
||||
|
||||
@@ -53,7 +52,7 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
guild (nextcord.Guild): Guild that was left.
|
||||
"""
|
||||
with Session(engine) as session:
|
||||
stmt = select(Guild).where(Guild.GuildId == guild.id)
|
||||
stmt = select(Guild).where(col(Guild.id == guild.id))
|
||||
guild_data = session.scalar(stmt)
|
||||
guild_data.Active = False
|
||||
session.commit()
|
||||
@@ -66,6 +65,6 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""Adds function to bot"""
|
||||
def setup(bot: commands.Bot) -> None:
|
||||
"""Adds function to bot."""
|
||||
bot.add_cog(GuildListener(bot))
|
||||
|
||||
@@ -7,8 +7,6 @@ from sqlmodel import col
|
||||
|
||||
from database.db import engine
|
||||
from database.models import Submission
|
||||
|
||||
# pylint: disable=import-error
|
||||
from utilities.utils import submit_score
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ from sqlalchemy import distinct, select
|
||||
from sqlalchemy.orm import Session, aliased
|
||||
from sqlmodel import col
|
||||
|
||||
# pylint: disable=import-error
|
||||
from database.db import engine
|
||||
from database.models import Category, CategoryGroup, Guild, Score
|
||||
|
||||
|
||||
Reference in New Issue
Block a user