Replaced legacy Union[] with new syntax

This commit is contained in:
2024-12-27 00:18:54 +01:00
parent 7b64f6938b
commit eed084cd91
6 changed files with 31 additions and 42 deletions

View File

@@ -1,6 +1,5 @@
import logging
import sys
from typing import Union
from discord import (
ApplicationContext,
@@ -160,10 +159,10 @@ class Admin(commands.Cog):
)
)
mod_role: Union[Role, None] = ds_utils.get(
mod_role: Role | None = ds_utils.get(
ctx.user.guild.roles, id=await config_get("moderators", "roles")
)
admin_chan: Union[TextChannel, None] = ds_utils.get(
admin_chan: TextChannel | None = ds_utils.get(
ctx.user.guild.channels,
id=await config_get("adminchat", "channels", "text"),
)
@@ -216,10 +215,10 @@ class Admin(commands.Cog):
)
)
mod_role: Union[Role, None] = ds_utils.get(
mod_role: Role | None = ds_utils.get(
ctx.user.guild.roles, id=await config_get("moderators", "roles")
)
admin_chan: Union[TextChannel, None] = ds_utils.get(
admin_chan: TextChannel | None = ds_utils.get(
ctx.user.guild.channels,
id=await config_get("adminchat", "channels", "text"),
)

View File

@@ -1,5 +1,5 @@
import logging
from typing import Any, Dict, Union
from typing import Any, Dict
from discord import ApplicationContext, Embed, option, TextChannel, Role
from discord import utils as ds_utils
@@ -108,9 +108,7 @@ class CustomChannels(commands.Cog):
bots: Dict[str, Any] = await config_get("bots")
for bot in bots:
role: Union[Role, None] = ds_utils.get(
ctx.user.guild.roles, id=bots[bot]["role"]
)
role: Role | None = ds_utils.get(ctx.user.guild.roles, id=bots[bot]["role"])
if role is not None:
await created_channel.set_permissions(
@@ -131,7 +129,7 @@ class CustomChannels(commands.Cog):
) -> None:
holo_user_ctx: HoloUser = HoloUser(ctx.user)
custom_channel: Union[TextChannel, None] = ds_utils.get(
custom_channel: TextChannel | None = ds_utils.get(
ctx.guild.channels, id=holo_user_ctx.customchannel
)
@@ -188,7 +186,7 @@ class CustomChannels(commands.Cog):
await ctx.defer()
custom_channel: Union[TextChannel, None] = ds_utils.get(
custom_channel: TextChannel | None = ds_utils.get(
ctx.guild.channels, id=holo_user_ctx.customchannel
)

View File

@@ -2,7 +2,7 @@ import logging
from logging import Logger
from os import makedirs
from pathlib import Path
from typing import Union, List, Dict, Any
from typing import List, Dict, Any
from uuid import uuid4
from discord import ApplicationContext, Embed, File, option, Role, TextChannel
@@ -54,10 +54,10 @@ class Data(commands.Cog):
)
)
mod_role: Union[Role, None] = ds_utils.get(
mod_role: Role | None = ds_utils.get(
ctx.user.guild.roles, id=await config_get("moderators", "roles")
)
admin_chan: Union[TextChannel, None] = ds_utils.get(
admin_chan: TextChannel | None = ds_utils.get(
ctx.user.guild.channels,
id=await config_get("adminchat", "channels", "text"),
)
@@ -126,10 +126,10 @@ class Data(commands.Cog):
)
)
mod_role: Union[Role, None] = ds_utils.get(
mod_role: Role | None = ds_utils.get(
ctx.user.guild.roles, id=await config_get("moderators", "roles")
)
admin_chan: Union[TextChannel, None] = ds_utils.get(
admin_chan: TextChannel | None = ds_utils.get(
ctx.user.guild.channels,
id=await config_get("adminchat", "channels", "text"),
)

View File

@@ -1,4 +1,4 @@
from typing import Dict, Any, Union
from typing import Dict, Any
from discord import Member, Message, TextChannel
from discord import utils as ds_utils
@@ -33,11 +33,11 @@ class Logger(commands.Cog):
@commands.Cog.listener()
async def on_member_join(self, member: Member) -> None:
welcome_chan: Union[TextChannel, None] = ds_utils.get(
welcome_chan: TextChannel | None = ds_utils.get(
self.client.get_guild(await config_get("guild")).channels,
id=await config_get("welcome", "channels", "text"),
)
rules_chan: Union[TextChannel, None] = ds_utils.get(
rules_chan: TextChannel | None = ds_utils.get(
self.client.get_guild(await config_get("guild")).channels,
id=await config_get("rules", "channels", "text"),
)