Made Pylint happy
This commit is contained in:
parent
8aec106671
commit
2c93e81be0
|
@ -4,12 +4,9 @@ from os import getenv
|
||||||
from naff import (
|
from naff import (
|
||||||
Client,
|
Client,
|
||||||
Intents,
|
Intents,
|
||||||
OptionTypes,
|
|
||||||
Permissions,
|
|
||||||
listen,
|
listen,
|
||||||
slash_command,
|
slash_command,
|
||||||
InteractionContext,
|
InteractionContext,
|
||||||
slash_option,
|
|
||||||
)
|
)
|
||||||
from naff.api import events
|
from naff.api import events
|
||||||
from naff.models.discord.embed import (
|
from naff.models.discord.embed import (
|
||||||
|
@ -19,10 +16,8 @@ from naff.models.discord.embed import (
|
||||||
EmbedFooter,
|
EmbedFooter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
from database import GuildSettings as GuildSettingsModel, JoinLeave
|
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from database import GuildSettings as GuildSettingsModel, JoinLeave
|
||||||
|
|
||||||
bot = Client(intents=Intents.ALL, debug_scope=387153131378835456)
|
bot = Client(intents=Intents.ALL, debug_scope=387153131378835456)
|
||||||
|
|
||||||
|
@ -86,7 +81,6 @@ async def on_member_leave(event: events.MemberRemove):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@slash_command(name="ping", description="Ping the bot")
|
@slash_command(name="ping", description="Ping the bot")
|
||||||
async def ping_command(ctx: InteractionContext):
|
async def ping_command(ctx: InteractionContext):
|
||||||
ctx.ephemeral = True
|
ctx.ephemeral = True
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# pylint: disable=consider-using-f-string
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from naff import (
|
from naff import (
|
||||||
|
|
|
@ -6,7 +6,6 @@ from naff import (
|
||||||
Client,
|
Client,
|
||||||
Extension,
|
Extension,
|
||||||
slash_command,
|
slash_command,
|
||||||
slash_option,
|
|
||||||
InteractionContext,
|
InteractionContext,
|
||||||
Modal,
|
Modal,
|
||||||
ParagraphText,
|
ParagraphText,
|
||||||
|
@ -22,7 +21,7 @@ from database import BotMessages as BotMessagesModel
|
||||||
# Template modal for creating/editing bot messages.
|
# Template modal for creating/editing bot messages.
|
||||||
message_creation_modal = Modal(
|
message_creation_modal = Modal(
|
||||||
custom_id="bot-message-create",
|
custom_id="bot-message-create",
|
||||||
title=f"Create a message as the bot",
|
title="Create a message as the bot",
|
||||||
components=[
|
components=[
|
||||||
ParagraphText(
|
ParagraphText(
|
||||||
custom_id="embeds",
|
custom_id="embeds",
|
||||||
|
@ -52,7 +51,6 @@ class BotMessages(Extension):
|
||||||
default_member_permissions=Permissions.MANAGE_GUILD,
|
default_member_permissions=Permissions.MANAGE_GUILD,
|
||||||
)
|
)
|
||||||
async def bot_message_create_command(self, ctx: InteractionContext):
|
async def bot_message_create_command(self, ctx: InteractionContext):
|
||||||
|
|
||||||
# Respond with the template modal. No values have been set in the modal, as it is
|
# Respond with the template modal. No values have been set in the modal, as it is
|
||||||
# a new message.
|
# a new message.
|
||||||
await ctx.send_modal(message_creation_modal)
|
await ctx.send_modal(message_creation_modal)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import random, string
|
import random
|
||||||
|
import string
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from naff import (
|
from naff import (
|
||||||
Extension,
|
Extension,
|
||||||
|
@ -17,7 +18,6 @@ from naff import (
|
||||||
SlashCommandChoice,
|
SlashCommandChoice,
|
||||||
Button,
|
Button,
|
||||||
ButtonStyles,
|
ButtonStyles,
|
||||||
Embed,
|
|
||||||
)
|
)
|
||||||
from naff.api import events
|
from naff.api import events
|
||||||
from naff.models.discord.enums import Permissions
|
from naff.models.discord.enums import Permissions
|
||||||
|
@ -60,12 +60,12 @@ class Gatekeep(Extension):
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def set_type_command(self, ctx: InteractionContext, type: str):
|
async def set_type_command(self, ctx: InteractionContext, type_: str):
|
||||||
gk: GatekeepModel
|
gk: GatekeepModel
|
||||||
gk, _ = GatekeepModel.get_or_create(guild_id=ctx.guild.id)
|
gk, _ = GatekeepModel.get_or_create(guild_id=ctx.guild.id)
|
||||||
gk.gatekeep_method = type
|
gk.gatekeep_method = type_
|
||||||
gk.save()
|
gk.save()
|
||||||
await ctx.send(f"Gatekeep type set to {type}", ephemeral=True)
|
await ctx.send(f"Gatekeep type set to {type_}", ephemeral=True)
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
name="gatekeep",
|
name="gatekeep",
|
||||||
|
@ -193,7 +193,8 @@ class Gatekeep(Extension):
|
||||||
|
|
||||||
if not welcome_channel:
|
if not welcome_channel:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"{user.mention} has been approved.\nNB: No welcome channel has been set – attempting to DM {user.mention}",
|
(f"{user.mention} has been approved.\n"
|
||||||
|
f"NB: No welcome channel has been set – attempting to DM {user.mention}"),
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
await user.send(
|
await user.send(
|
||||||
|
@ -204,7 +205,8 @@ class Gatekeep(Extension):
|
||||||
channel = await ctx.guild.fetch_channel(jl.message_channel)
|
channel = await ctx.guild.fetch_channel(jl.message_channel)
|
||||||
if not channel:
|
if not channel:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
f"{user.mention} has been approved.\nNB: No welcome channel has been set – attempting to DM {user.mention}",
|
(f"{user.mention} has been approved.\n"
|
||||||
|
f"NB: No welcome channel has been set – attempting to DM {user.mention}"),
|
||||||
ephemeral=True,
|
ephemeral=True,
|
||||||
)
|
)
|
||||||
await user.send(
|
await user.send(
|
||||||
|
@ -406,10 +408,6 @@ class Gatekeep(Extension):
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setup(client: Client):
|
def setup(client: Client):
|
||||||
GatekeepModel.create_table()
|
GatekeepModel.create_table()
|
||||||
GatekeepCaptchasModel.create_table()
|
GatekeepCaptchasModel.create_table()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# pylint: disable=unsubscriptable-object
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from naff import (
|
from naff import (
|
||||||
|
@ -63,7 +64,6 @@ class Infractions(Extension):
|
||||||
# await ctx.send(embed=embeds, ephemeral=True)
|
# await ctx.send(embed=embeds, ephemeral=True)
|
||||||
paginator = Paginator.create_from_embeds(self.client, *embeds)
|
paginator = Paginator.create_from_embeds(self.client, *embeds)
|
||||||
await paginator.send(ctx)
|
await paginator.send(ctx)
|
||||||
paginator.send
|
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
name="user-infractions",
|
name="user-infractions",
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
# pylint: disable=not-an-iterable
|
||||||
|
# pylint: disable=unsubscriptable-object
|
||||||
|
# pylint: disable=logging-fstring-interpolation
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from time import sleep
|
from typing import List, Tuple
|
||||||
from typing import Dict, List, Tuple
|
|
||||||
from naff import (
|
from naff import (
|
||||||
Client,
|
Client,
|
||||||
Extension,
|
Extension,
|
||||||
|
@ -29,8 +31,8 @@ from naff import (
|
||||||
from naff.api import events
|
from naff.api import events
|
||||||
from naff.client.errors import HTTPException
|
from naff.client.errors import HTTPException
|
||||||
|
|
||||||
from database import Polls as PollsModel, PollVotes as PollVotesModel
|
|
||||||
from peewee import fn
|
from peewee import fn
|
||||||
|
from database import Polls as PollsModel, PollVotes as PollVotesModel
|
||||||
|
|
||||||
PollOptions = List[Tuple[str | None, str]]
|
PollOptions = List[Tuple[str | None, str]]
|
||||||
|
|
||||||
|
@ -114,7 +116,7 @@ def generate_poll_embed(
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
def num_to_emoji(num: int) -> str:
|
def num_to_emoji(num: int) -> str: # pylint: disable=too-many-return-statements
|
||||||
match num:
|
match num:
|
||||||
case 0:
|
case 0:
|
||||||
return "0️⃣"
|
return "0️⃣"
|
||||||
|
@ -140,7 +142,7 @@ def num_to_emoji(num: int) -> str:
|
||||||
return "🔟"
|
return "🔟"
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
raise ValueError(f"Invalid number: `num` must be 0 <= num <= 10.")
|
raise ValueError("Invalid number: `num` must be 0 <= num <= 10.")
|
||||||
|
|
||||||
|
|
||||||
class Polls(Extension):
|
class Polls(Extension):
|
||||||
|
@ -150,7 +152,7 @@ class Polls(Extension):
|
||||||
@listen(events.Ready)
|
@listen(events.Ready)
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
await self.poll_expiry_check()
|
await self.poll_expiry_check()
|
||||||
self.poll_expiry_check.start()
|
self.poll_expiry_check.start() # pylint: disable=no-member
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
name="polls",
|
name="polls",
|
||||||
|
@ -178,7 +180,7 @@ class Polls(Extension):
|
||||||
required=False,
|
required=False,
|
||||||
opt_type=OptionTypes.BOOLEAN,
|
opt_type=OptionTypes.BOOLEAN,
|
||||||
)
|
)
|
||||||
async def create_poll(
|
async def create_poll( # pylint: disable=too-many-locals
|
||||||
self,
|
self,
|
||||||
ctx: InteractionContext,
|
ctx: InteractionContext,
|
||||||
*,
|
*,
|
||||||
|
@ -307,7 +309,7 @@ class Polls(Extension):
|
||||||
poll_entry.save()
|
poll_entry.save()
|
||||||
|
|
||||||
@listen(events.Button)
|
@listen(events.Button)
|
||||||
async def on_button(self, button: events.Button):
|
async def on_button(self, button: events.Button): #pylint: disable=too-many-branches,too-many-statements
|
||||||
ctx = button.context
|
ctx = button.context
|
||||||
|
|
||||||
# Ensure that the pressed button is a vote button.
|
# Ensure that the pressed button is a vote button.
|
||||||
|
@ -404,7 +406,7 @@ class Polls(Extension):
|
||||||
options: PollOptions = json.loads(poll_entry.options)
|
options: PollOptions = json.loads(poll_entry.options)
|
||||||
votes = len(options) * [0]
|
votes = len(options) * [0]
|
||||||
|
|
||||||
for i, vote in enumerate(votes_q):
|
for vote in votes_q:
|
||||||
votes[int(vote.option)] = vote.count
|
votes[int(vote.option)] = vote.count
|
||||||
|
|
||||||
embed = generate_poll_embed(
|
embed = generate_poll_embed(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from re import S
|
# pylint: disable=not-an-iterable
|
||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
import logging
|
import logging
|
||||||
from naff import (
|
from naff import (
|
||||||
|
@ -11,7 +11,6 @@ from naff import (
|
||||||
InteractionContext,
|
InteractionContext,
|
||||||
Role,
|
Role,
|
||||||
Embed,
|
Embed,
|
||||||
EmbedField,
|
|
||||||
AutocompleteContext,
|
AutocompleteContext,
|
||||||
Select,
|
Select,
|
||||||
SelectOption,
|
SelectOption,
|
||||||
|
@ -21,7 +20,6 @@ from naff import (
|
||||||
Message,
|
Message,
|
||||||
)
|
)
|
||||||
from naff.api import events
|
from naff.api import events
|
||||||
from naff import components
|
|
||||||
from database import (
|
from database import (
|
||||||
SelfRoles as SelfRolesModel,
|
SelfRoles as SelfRolesModel,
|
||||||
SelfRoleGroups as SelfRoleGroupsModel,
|
SelfRoleGroups as SelfRoleGroupsModel,
|
||||||
|
@ -621,10 +619,6 @@ class SelfRoles(Extension):
|
||||||
await ctx.send("Role group message regenerated!", ephemeral=True)
|
await ctx.send("Role group message regenerated!", ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(
|
||||||
name="role",
|
name="role",
|
||||||
description="Manage your roles",
|
description="Manage your roles",
|
||||||
|
@ -648,7 +642,7 @@ class SelfRoles(Extension):
|
||||||
)
|
)
|
||||||
|
|
||||||
if role_q is None:
|
if role_q is None:
|
||||||
await ctx.send(f"Failed to retrieve self-role.", ephemeral=True)
|
await ctx.send("Failed to retrieve self-role.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
role = await ctx.guild.fetch_role(role)
|
role = await ctx.guild.fetch_role(role)
|
||||||
|
@ -732,7 +726,7 @@ class SelfRoles(Extension):
|
||||||
await ctx.defer(ephemeral=True)
|
await ctx.defer(ephemeral=True)
|
||||||
role = await ctx.guild.fetch_role(role)
|
role = await ctx.guild.fetch_role(role)
|
||||||
if role is None:
|
if role is None:
|
||||||
await ctx.send(f"Failed to retrieve role.", ephemeral=True)
|
await ctx.send("Failed to retrieve role.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
if role not in ctx.author.roles:
|
if role not in ctx.author.roles:
|
||||||
|
|
Loading…
Reference in New Issue