Skip to content

Sourcery refactored master branch #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jun 26, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Jerry-py June 26, 2023 22:11
Comment on lines -259 to +266
"Open invite to beerparty! React with 🍻 to join!" + reason
)
f"Open invite to beerparty! React with 🍻 to join!{reason}"
)
await msg.add_reaction("\U0001f37b")
await asyncio.sleep(60)
msg = await ctx.channel.fetch_message(msg.id)
users = [user async for user in msg.reactions[0].users()]
users.remove(self.bot.user)
if len(users) == 0:
if not users:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Fun._beerparty refactored with the following changes:

help_command = self.bot.get_command("help")
if help_command:
if help_command := self.bot.get_command("help"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function General._source refactored with the following changes:

Comment on lines -100 to +99
title="Definition of {}".format(word),
title=f"Definition of {word}",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function General.define refactored with the following changes:

if official_helper_role not in ctx.author.roles:
return False
return True
return official_helper_role in ctx.author.roles
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Helper.cog_check refactored with the following changes:

Comment on lines -178 to +177
embed.description = "{} **Action:** {}\n**Reason:** {}\n".format(
icon, action_string.title(), reason
embed.description = (
f"{icon} **Action:** {action_string.title()}\n**Reason:** {reason}\n"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Helper.log refactored with the following changes:

Comment on lines -265 to +277
check_made = self.check_member_permission(ctx, member)
if check_made:
if check_made := self.check_member_permission(ctx, member):
return await self.bot.reply(ctx, check_made)
else:
try:
await member.send(
"You have been :hammer: **Banned** :hammer: from "
f"**{ctx.guild.name}**. \nReason: {reason}"
)
except (discord.Forbidden, discord.HTTPException):
pass
await ctx.guild.ban(member, reason=reason, delete_message_days=7)
await self.bot.reply(ctx, f"Banned {member.mention}")
evidence = await self.capture_evidence(ctx)
await self.log(action="ban", moderator=ctx.author, member=member,
undo=False, reason=reason, duration=None, evidence=evidence)
try:
await member.send(
"You have been :hammer: **Banned** :hammer: from "
f"**{ctx.guild.name}**. \nReason: {reason}"
)
except (discord.Forbidden, discord.HTTPException):
pass
await ctx.guild.ban(member, reason=reason, delete_message_days=7)
await self.bot.reply(ctx, f"Banned {member.mention}")
evidence = await self.capture_evidence(ctx)
await self.log(action="ban", moderator=ctx.author, member=member,
undo=False, reason=reason, duration=None, evidence=evidence)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.ban refactored with the following changes:

Comment on lines -330 to +327
check_made = self.check_member_permission(ctx, member)
if check_made:
if check_made := self.check_member_permission(ctx, member):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.mute refactored with the following changes:

Comment on lines -369 to +365
check_made = self.check_member_permission(ctx, member)
if check_made:
if check_made := self.check_member_permission(ctx, member):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.unmute refactored with the following changes:

Comment on lines -405 to +406
check_made = self.check_member_permission(ctx, user)
if check_made:
if check_made := self.check_member_permission(ctx, user):
counter_dict["not_banned"].append(user)
continue
await ctx.guild.ban(user) # type: ignore
counter_dict["banned"].append(user)
embed = discord.Embed(color=discord.Color.red())
description = "Following members were banned:\n{}".format(
", ".join(f"{user.mention}" for user in counter_dict["banned"])
)
description = f'Following members were banned:\n{", ".join(f"{user.mention}" for user in counter_dict["banned"])}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.massban refactored with the following changes:

Comment on lines -440 to +432
check = self.check_member_permission(ctx, member, priv_level=0)
if check:
if check := self.check_member_permission(ctx, member, priv_level=0):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.warn refactored with the following changes:

Comment on lines -509 to +502
if moderator:
moderator = moderator.mention
else:
moderator = "Unknown"
moderator = moderator.mention if moderator else "Unknown"
embed.add_field(
name="`{}.` Reason: {}".format(i, warning.reason),
name=f"`{i}.` Reason: {warning.reason}",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.warnings refactored with the following changes:

Comment on lines -674 to +662
elif not message and ctx.message.reference:
elif not message:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.delete refactored with the following changes:

Comment on lines -865 to +867
if not self.bot.raid_mode_enabled:
if self.bot.raid_checker.possible_raid:
self.bot.raid_mode_enabled = True
await self.bot.reply(ctx, "Raid mode is now enabled.")
for member in self.bot.raid_checker.cache:
if self.bot.raid_checker.check(member):
await member.ban(
reason="Raid mode enabled and met raid criteria."
)
else:
await self.bot.reply(
ctx, "There is no raid that has been detected yet."
)
else:
if self.bot.raid_mode_enabled:
await self.bot.reply(ctx, "Raid mode is already enabled.")

elif self.bot.raid_checker.possible_raid:
self.bot.raid_mode_enabled = True
await self.bot.reply(ctx, "Raid mode is now enabled.")
for member in self.bot.raid_checker.cache:
if self.bot.raid_checker.check(member):
await member.ban(
reason="Raid mode enabled and met raid criteria."
)
else:
await self.bot.reply(
ctx, "There is no raid that has been detected yet."
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Moderation.raid_mode_enable refactored with the following changes:

Comment on lines -75 to +88
tcr = self.bot.get_guild(681882711945641997)
if tcr:
if tcr := self.bot.get_guild(681882711945641997):
if tcr.get_role(795145820210462771):
statuses.append(
random.choice(tcr.get_role(795145820210462771).members).name
) # type: ignore
if tcr.get_role(737517726737629214):
statuses.append(
random.choice(tcr.get_role(737517726737629214).members).name
+ " (Server Booster)"
) # type: ignore
f"{random.choice(tcr.get_role(737517726737629214).members).name} (Server Booster)"
)

await self.bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=random.choice(statuses)
+ " | "
+ self.bot.default_prefixes[0]
+ "help",
name=f"{random.choice(statuses)} | {self.bot.default_prefixes[0]}help",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TaskCog.status_change refactored with the following changes:

Comment on lines -71 to -74
chunk = tuple(itertools.islice(it, n))
if not chunk:
if chunk := tuple(itertools.islice(it, n)):
yield chunk
else:
return
yield chunk
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function grouper refactored with the following changes:

Comment on lines -393 to +391
jishaku = self.get_cog("Jishaku")
if jishaku:
if jishaku := self.get_cog("Jishaku"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CodingBot.setup_hook refactored with the following changes:

Comment on lines -427 to +424
rules = member.guild.rules_channel
if rules:
if rules := member.guild.rules_channel:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function CodingBot.on_member_join refactored with the following changes:

title="compiling **[** {} **]**".format(
int(time.time()) - self.timestamp
)
title=f"compiling **[** {int(time.time()) - self.timestamp} **]**"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Piston.timer refactored with the following changes:

Comment on lines +68 to +74
elif output:
if len(output[-1].split("\n")) > 15:
output.append(line + "\n")
else:
output[-1] += line + "\n"
else:
output.append(line + "\n")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Piston.get_code_out refactored with the following changes:

Comment on lines -154 to +151
if interaction.user == self.author:
return True
return False
return interaction.user == self.author
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Piston.interaction_check refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants