Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from The-4th-Hokage/deepsource-transform-62c6…
Browse files Browse the repository at this point in the history
…1591

Format code with black, yapf, autopep8 and isort
Dhruvacube authored Feb 2, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 9fa4e48 + 0e255ad commit 0d3dbe5
Showing 2 changed files with 135 additions and 151 deletions.
220 changes: 100 additions & 120 deletions minato_namikaze/bot_files/cogs/developer.py
Original file line number Diff line number Diff line change
@@ -31,12 +31,13 @@ def owners(ctx):

async def _send_guilds(self, ctx, guilds, title):
if len(guilds) == 0:
await ctx.send(embed=ErrorEmbed(description="No such guild was found."))
await ctx.send(embed=ErrorEmbed(
description="No such guild was found."))
return

all_pages = []

for chunk in [guilds[i: i + 20] for i in range(0, len(guilds), 20)]:
for chunk in [guilds[i:i + 20] for i in range(0, len(guilds), 20)]:
page = Embed(title=title)

for guild in chunk:
@@ -66,15 +67,15 @@ async def dev(self, ctx, command=None):
await ctx.send_help(ctx.command)
return

@dev.group(name="postcommand", alisases=["postfates", "post_commands_to_fates_list"])
@dev.group(name="postcommand",
alisases=["postfates", "post_commands_to_fates_list"])
async def post_commands_to_fates_list(self, ctx):
"""Post all the commands to FATES LIST"""
start_time = time.time()
await self.bot.change_presence(
status=discord.Status.dnd,
activity=discord.Activity(
type=discord.ActivityType.watching, name="over Naruto"
),
activity=discord.Activity(type=discord.ActivityType.watching,
name="over Naruto"),
)
post_start = await ctx.send("Posting :outbox_tray:")
await PostStats(self.bot).post_commands()
@@ -89,12 +90,12 @@ async def post_commands_to_fates_list(self, ctx):
)
await self.bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(
type=discord.ActivityType.watching, name="over Naruto"
),
activity=discord.Activity(type=discord.ActivityType.watching,
name="over Naruto"),
)

@dev.group(name="deletecommand", alisases=["postfates", "deletefateslistcommand"])
@dev.group(name="deletecommand",
alisases=["postfates", "deletefateslistcommand"])
async def deletefateslistcommand(self, ctx):
"""Deletes all the commands from FATES LIST"""
start_time = time.time()
@@ -118,9 +119,8 @@ async def deletefateslistcommand(self, ctx):
)
await self.bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(
type=discord.ActivityType.watching, name="over Naruto"
),
activity=discord.Activity(type=discord.ActivityType.watching,
name="over Naruto"),
)

@dev.group(name="sharedservers", usage="<user>")
@@ -146,25 +146,19 @@ async def createinvite(self, ctx, *, argument: int):
invite = (await guild.invites())[0]
except:
try:
invite = (await guild.text_channels())[0].create_invite(max_age=120)
invite = (await guild.text_channels())[0].create_invite(
max_age=120)
except:
await ctx.send(
embed=ErrorEmbed(
description="No permissions to create an invite link."
)
await ctx.send(embed=ErrorEmbed(
description="No permissions to create an invite link.")
)
return

await ctx.send(
embed=Embed(
description=f"Here is the invite link: {invite.url}")
)
await ctx.send(embed=Embed(
description=f"Here is the invite link: {invite.url}"))
except:
await ctx.send(
embed=ErrorEmbed(
description="Sorry! This is not possible for this server!"
)
)
await ctx.send(embed=ErrorEmbed(
description="Sorry! This is not possible for this server!"))

@dev.group(invoke_without_command=True, name="eval")
@commands.check(owners)
@@ -224,7 +218,8 @@ def paginate(text: str):
ret = await func()
except Exception as e:
value = stdout.getvalue()
err = await ctx.send(f"```py\n{value}{traceback.format_exc()}\n```")
err = await ctx.send(f"```py\n{value}{traceback.format_exc()}\n```"
)
else:
value = stdout.getvalue()
if ret is None:
@@ -257,21 +252,19 @@ def paginate(text: str):
else:
await ctx.message.add_reaction("\u2705")


@dev.group(invoke_without_command=True)
@commands.check(owners)
async def sync(self, ctx):
"""Sync with GitHub and reload all the cogs"""
embed = Embed(
title="Syncing...", description=":joy: Syncing and reloading cogs."
)
embed = Embed(title="Syncing...",
description=":joy: Syncing and reloading cogs.")
embed.set_footer(text=f"{ctx.author} | Minato Namikaze")
msg = await ctx.send(embed=embed)
async with ctx.channel.typing():
output = sp.getoutput("git pull")
embed = Embed(
title="Synced", description="Synced with GitHub and reloaded all the cogs."
)
title="Synced",
description="Synced with GitHub and reloaded all the cogs.")
# Reload Cogs as well
cog_dir = Path(__file__).resolve(strict=True).parent.parent
error_collection = []
@@ -281,8 +274,7 @@ async def sync(self, ctx):
if i.endswith(".py"):
try:
self.bot.reload_extension(
f"bot_files.cogs.{file.strip(' ')}.{i[:-3]}"
)
f"bot_files.cogs.{file.strip(' ')}.{i[:-3]}")
except Exception as e:
return await ctx.send(f"```py\n{e}```")
else:
@@ -295,20 +287,17 @@ async def sync(self, ctx):

if error_collection:
err = "\n".join(
[f"**{g[0]}** ```diff\n- {g[1]}```" for g in error_collection]
)
[f"**{g[0]}** ```diff\n- {g[1]}```" for g in error_collection])
return await ctx.send(
f"Attempted to reload all extensions, was able to reload, "
f"however the following failed...\n\n{err}"
)
f"however the following failed...\n\n{err}")

await msg.edit(embed=embed)

@dev.group(name="pretend")
@commands.check(owners)
async def pretend(
self, ctx: commands.Context, target: discord.User, *, command_string: str
):
async def pretend(self, ctx: commands.Context, target: discord.User, *,
command_string: str):
"""Execute my commands pretending as others | usage: <member.mention> <command.name> eg: )own as @Minato angel"""
if ctx.guild:
# Try to upgrade to a Member instance
@@ -318,21 +307,20 @@ async def pretend(

with contextlib.suppress(discord.HTTPException):
target_member = ctx.guild.get_member(
target.id
) or await ctx.guild.fetch_member(target.id)
target.id) or await ctx.guild.fetch_member(target.id)

target = target_member or target

alt_ctx = await copy_context_with(
ctx, author=target, content=ctx.prefix + command_string
)
alt_ctx = await copy_context_with(ctx,
author=target,
content=ctx.prefix + command_string)

if alt_ctx.command is None:
if alt_ctx.invoked_with is None:
return await ctx.send(
"This bot has been hard-configured to ignore this user."
)
return await ctx.send(f'Command "{alt_ctx.invoked_with}" is not found')
"This bot has been hard-configured to ignore this user.")
return await ctx.send(
f'Command "{alt_ctx.invoked_with}" is not found')

return await alt_ctx.command.invoke(alt_ctx)

@@ -348,13 +336,11 @@ async def changestat(self, ctx):
@commands.check(owners)
async def stream(self, ctx, *, activity="placeholder (owner to lazy lol)"):
"""Streaming Activity"""
await self.bot.change_presence(
activity=discord.Streaming(
status=discord.Status.idle,
name=activity,
url="https://www.twitch.tv/dhruvacube",
)
)
await self.bot.change_presence(activity=discord.Streaming(
status=discord.Status.idle,
name=activity,
url="https://www.twitch.tv/dhruvacube",
))
await ctx.send(
f"```diff\n- Changed activity to {activity} using Stream status.```"
)
@@ -363,62 +349,61 @@ async def stream(self, ctx, *, activity="placeholder (owner to lazy lol)"):
@commands.check(owners)
async def game(self, ctx, *, activity="placeholder (owner to lazy lol)"):
"""Game Activity"""
await self.bot.change_presence(
status=discord.Status.idle, activity=discord.Game(name=activity)
)
await ctx.send(f"```md\n# Changed activity to {activity} using Game status.```")
await self.bot.change_presence(status=discord.Status.idle,
activity=discord.Game(name=activity))
await ctx.send(
f"```md\n# Changed activity to {activity} using Game status.```")

@changestat.group(invoke_without_command=True)
@commands.check(owners)
async def watching(self, ctx, *, activity="placeholder (owner to lazy lol)"):
async def watching(self,
ctx,
*,
activity="placeholder (owner to lazy lol)"):
"""Watching activity"""
await self.bot.change_presence(
activity=discord.Activity(
status=discord.Status.idle,
type=discord.ActivityType.watching,
name=activity,
)
)
await self.bot.change_presence(activity=discord.Activity(
status=discord.Status.idle,
type=discord.ActivityType.watching,
name=activity,
))
await ctx.send(
f"```arm\nChanged activity to {activity} using Watching status.```"
)

@changestat.group(invoke_without_command=True)
@commands.check(owners)
async def listening(self, ctx, *, activity="placeholder (owner to lazy lol)"):
async def listening(self,
ctx,
*,
activity="placeholder (owner to lazy lol)"):
"""Listenting Activity"""
await self.bot.change_presence(
activity=discord.Activity(
status=discord.Status.idle,
type=discord.ActivityType.listening,
name=activity,
)
)
await self.bot.change_presence(activity=discord.Activity(
status=discord.Status.idle,
type=discord.ActivityType.listening,
name=activity,
))
await ctx.send(
f"```fix\nChanged activity to {activity} using Listening status.```"
)

# on message event
@commands.Cog.listener()
async def on_message(self, message):
if (
self.bot.user.mentioned_in(message)
and message.mention_everyone is False
and message.content.lower()
in (f"<@!{self.bot.application_id}>", f"<@{self.bot.application_id}>")
or message.content.lower()
in (
f"<@!{self.bot.application_id}> prefix",
f"<@{self.bot.application_id}> prefix",
)
) and not message.author.bot:
if (self.bot.user.mentioned_in(message)
and message.mention_everyone is False
and message.content.lower() in
(f"<@!{self.bot.application_id}>", f"<@{self.bot.application_id}>")
or message.content.lower() in (
f"<@!{self.bot.application_id}> prefix",
f"<@{self.bot.application_id}> prefix",
)) and not message.author.bot:
await message.channel.send(
"The prefix is **)** ,A full list of all commands is available by typing ```)help```"
)

if message.channel.id in (
ChannelAndMessageId.error_logs_channel.value,
ChannelAndMessageId.traceback_channel.value,
ChannelAndMessageId.error_logs_channel.value,
ChannelAndMessageId.traceback_channel.value,
):
try:
await message.publish()
@@ -434,19 +419,17 @@ async def on_guild_remove(self, guild):
e34.set_thumbnail(url=guild.icon.url)
if guild.banner:
e34.set_image(url=guild.banner.with_format("png").url)
c = (
self.bot.get_channel(
ChannelAndMessageId.serverlog_channel2.value)
if not self.bot.local
else self.bot.get_channel(ChannelAndMessageId.serverlog_channel1.value)
)
c = (self.bot.get_channel(
ChannelAndMessageId.serverlog_channel2.value)
if not self.bot.local else self.bot.get_channel(
ChannelAndMessageId.serverlog_channel1.value))
e34.add_field(name="**Total Members**", value=guild.member_count)
e34.add_field(
name="**Bots**", value=sum(1 for member in guild.members if member.bot)
)
e34.add_field(
name="**Region**", value=str(guild.region).capitalize(), inline=True
)
e34.add_field(name="**Bots**",
value=sum(1 for member in guild.members
if member.bot))
e34.add_field(name="**Region**",
value=str(guild.region).capitalize(),
inline=True)
e34.add_field(name="**Server ID**", value=guild.id, inline=True)
await c.send(
content=f"We are now currently at **{len(self.bot.guilds)+1} servers**",
@@ -460,8 +443,7 @@ async def on_guild_remove(self, guild):
async def on_guild_join(self, guild):
inviter_or_guild_owner = await self.bot.get_bot_inviter(guild)
welcome_channel = await self.bot.get_welcome_channel(
guild, inviter_or_guild_owner
)
guild, inviter_or_guild_owner)
try:
img = random.choice(self.minato_gif)
file = discord.File(join(self.BOT.minato_gif, img), filename=img)
@@ -493,26 +475,24 @@ async def on_guild_join(self, guild):

# Send it to server count channel the support server
try:
e34 = discord.Embed(
title=f"{guild.name}", color=discord.Color.green(), description="Added"
)
e34 = discord.Embed(title=f"{guild.name}",
color=discord.Color.green(),
description="Added")
if guild.icon:
e34.set_thumbnail(url=guild.icon.url)
if guild.banner:
e34.set_image(url=guild.banner.with_format("png").url)
c = (
self.bot.get_channel(
ChannelAndMessageId.serverlog_channel2.value)
if self.bot.local
else self.bot.get_channel(ChannelAndMessageId.serverlog_channel1.value)
)
c = (self.bot.get_channel(
ChannelAndMessageId.serverlog_channel2.value)
if self.bot.local else self.bot.get_channel(
ChannelAndMessageId.serverlog_channel1.value))
e34.add_field(name="**Total Members**", value=guild.member_count)
e34.add_field(
name="**Bots**", value=sum(1 for member in guild.members if member.bot)
)
e34.add_field(
name="**Region**", value=str(guild.region).capitalize(), inline=True
)
e34.add_field(name="**Bots**",
value=sum(1 for member in guild.members
if member.bot))
e34.add_field(name="**Region**",
value=str(guild.region).capitalize(),
inline=True)
e34.add_field(name="**Server ID**", value=guild.id, inline=True)
await c.send(
content=f"We are now currently at **{len(self.bot.guilds)+1} servers**",
Loading

0 comments on commit 0d3dbe5

Please sign in to comment.