Skip to content

Commit

Permalink
Merge pull request #210 from IgKniteDev/develop
Browse files Browse the repository at this point in the history
🎨 [tuning] Improved code syntax in some areas
  • Loading branch information
hitblast authored Mar 24, 2023
2 parents 6b7e479 + 04ef2ab commit e4217f2
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
5 changes: 3 additions & 2 deletions cogs/customization.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ async def _makerole(
) -> None:
color = get_color(color)
await inter.guild.create_role(name=name, color=color)
embed = disnake.Embed(description=f'Role `{name}` has been created.', color=color)

embed = core.TypicalEmbed().set_description(f'Role `{name}` has been created.')
await inter.send(embed=embed)

# assignrole
Expand Down Expand Up @@ -138,7 +139,7 @@ async def _makeinvite(

embed = (
core.TypicalEmbed(inter)
.set_title(value='Created a new invite!')
.set_title('Created a new invite!')
.add_field(name='Link', value=f'https://discord.gg/{invite.code}')
.add_field(name='Code', value=f'`{invite.code}`')
.add_field(
Expand Down
11 changes: 4 additions & 7 deletions cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
from disnake.ext import commands

import core
from core.embeds import TypicalEmbed


# Backend for ping-labelled commands.
# Do not use it within other commands unless really necessary.
async def _ping_backend(inter: disnake.CommandInteraction) -> TypicalEmbed:
async def _ping_backend(inter: disnake.CommandInteraction) -> core.TypicalEmbed:
system_latency = round(inter.bot.latency * 1000)

start_time = time.time()
Expand Down Expand Up @@ -97,9 +96,7 @@ async def _avatar_backend(
member = member or inter.author

embed = (
core.TypicalEmbed(inter)
.set_title(value='Here\'s what I found!')
.set_image(url=member.avatar)
core.TypicalEmbed(inter).set_title('Here\'s what I found!').set_image(url=member.avatar)
)

await inter.send(embed=embed)
Expand Down Expand Up @@ -132,9 +129,9 @@ async def _ping(self, inter: disnake.CommandInteraction) -> None:
async def help(inter):
embed = (
core.TypicalEmbed(inter, disabled_footer=True)
.set_title(value='Hey there! I\'m IgKnite.')
.set_title('Hey there! I\'m IgKnite.')
.set_description(
value='I\'m a bot with no text commands (you heard that right) '
'I\'m a bot with no text commands (you heard that right) '
+ 'and I\'m here to help you manage and moderate your Discord server alongside'
+ 'having a midnight music party with your friends in a random voice channel. '
+ 'Looking forward to being friends with you!'
Expand Down
8 changes: 4 additions & 4 deletions cogs/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def _userinfo_backend(

embed = (
core.TypicalEmbed(inter)
.set_title(value=str(member))
.set_title(str(member))
.add_field(name='Status', value=member.status)
.add_field(
name='Birth',
Expand Down Expand Up @@ -184,7 +184,7 @@ async def _userinfo_message(
async def _roleinfo(self, inter: disnake.CommandInteraction, role: disnake.Role) -> None:
embed = (
core.TypicalEmbed(inter)
.set_title(value=f'Role information: @{role.name}')
.set_title(f'Role information: @{role.name}')
.add_field(
name='Birth',
value=datetime.strptime(str(role.created_at), '%Y-%m-%d %H:%M:%S.%f%z').strftime(
Expand Down Expand Up @@ -222,7 +222,7 @@ async def page_loader(page_num: int) -> core.TypicalEmbed:
page = page_num
embed = (
core.TypicalEmbed(inter)
.set_title(value='Active Invites')
.set_title('Active Invites')
.set_footer(text=f'{page}/{top_page}')
)

Expand Down Expand Up @@ -309,7 +309,7 @@ async def _revokeinvites(
)
@commands.has_any_role(LockRoles.mod, LockRoles.admin)
async def _audit(self, inter: disnake.CommandInteraction, limit: int = 5):
embed = core.TypicalEmbed(inter).set_title(value=f'Audit Log ({limit} entries)')
embed = core.TypicalEmbed(inter).set_title(f'Audit Log ({limit} entries)')

async for audit_entry in inter.guild.audit_logs(limit=limit):
embed.add_field(
Expand Down
18 changes: 9 additions & 9 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ async def senddm(
embed = (
core.TypicalEmbed(inter)
.add_field('Message: ', msg)
.set_title(value=f'{inter.author.display_name} has sent you a message!')
.set_title(f'{inter.author.display_name} has sent you a message!')
.set_thumbnail(url=inter.author.avatar.url)
)

Expand All @@ -373,7 +373,7 @@ async def senddm(
dm_permission=False,
)
async def _pins(self, inter: disnake.CommandInteraction) -> None:
embed = core.TypicalEmbed(inter).set_title(value='Pinned Messages 📌')
embed = core.TypicalEmbed(inter).set_title('Pinned Messages 📌')
pins = await inter.channel.pins()
if pins:
for count, pin in enumerate(pins):
Expand All @@ -383,7 +383,7 @@ async def _pins(self, inter: disnake.CommandInteraction) -> None:
inline=False,
)
else:
embed.set_description(value='There are no pinned messages in this channel.')
embed.set_description('There are no pinned messages in this channel.')

await inter.send(embed=embed)

Expand Down Expand Up @@ -489,8 +489,8 @@ async def _banword(self, inter: disnake.CommandInteraction, keywords: str) -> No

embed = (
core.TypicalEmbed(inter)
.set_title(value='Added these words to banned list:')
.set_description(value=', '.join(keywords))
.set_title('Added these words to banned list:')
.set_description(', '.join(keywords))
)
await inter.send(embed=embed, ephemeral=True)

Expand Down Expand Up @@ -533,8 +533,8 @@ async def _showbannedwords(self, inter: disnake.CommandInteraction) -> None:
words += f'{item} \n'
embed = (
core.TypicalEmbed(inter)
.set_title(value='Here\'s the list of banned words:')
.set_description(value=words)
.set_title('Here\'s the list of banned words:')
.set_description(words)
)
await inter.send(embed=embed)

Expand All @@ -554,8 +554,8 @@ async def _showbannedwords(self, inter: disnake.CommandInteraction) -> None:
async def _clearnicks(self, inter: disnake.CommandInteraction) -> None:
embed = (
core.TypicalEmbed(inter, disabled_footer=True, is_error=True)
.set_title(value='Are you sure?')
.set_description(value='This action cannot be undone.')
.set_title('Are you sure?')
.set_description('This action cannot be undone.')
)

await inter.send(embed=embed, view=ClearnickCommandView(inter), ephemeral=True)
Expand Down
4 changes: 2 additions & 2 deletions cogs/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def create_embed(

embed = (
core.TypicalEmbed(inter)
.set_title(value=self.source.title)
.set_title(self.source.title)
.add_field(name='Duration', value=duration)
.add_field(name='Requester', value=self.requester.mention)
.set_image(url=self.source.thumbnail)
Expand Down Expand Up @@ -768,7 +768,7 @@ async def page_loader(page_num: int) -> core.TypicalEmbed:

embed = (
core.TypicalEmbed(inter)
.set_title(value='Current Queue')
.set_title('Current Queue')
.set_footer(text=f'{page}/{top_page}')
)

Expand Down
4 changes: 2 additions & 2 deletions core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from . import chain as chain
from . import datacls as datacls
from .bot import *
from .embeds import *
from .ui import *

# Set version number.
__version_info__ = ('2023', '3', '23') # Year.Month.Day
__version_info__ = ('2023', '3', '24') # Year.Month.Day
__version__ = '.'.join(__version_info__)

# Set bot metadata.
Expand Down
File renamed without changes.

0 comments on commit e4217f2

Please sign in to comment.