Allow formatter to run on forks (#28)

* Allow formatter to run on forks

* Sometimes RTFM does save some time

* Automatically fix formatting for same repo PRs

* Apply black formatting
This commit is contained in:
TSRBerry 2023-04-01 18:43:56 +02:00 committed by GitHub
parent 9caa1f6b72
commit 5e2ce2abaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 24 deletions

View file

@ -12,6 +12,7 @@ jobs:
black:
name: Python Black
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v3
@ -47,3 +48,12 @@ jobs:
git commit -m "Apply black formatting"
git push
fork-black:
name: Python Black
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name != github.repository
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable

View file

@ -47,7 +47,7 @@ wanted_jsons = [
"data/userlog.json",
"data/invites.json",
"data/macros.json",
"data/persistent_roles.json"
"data/persistent_roles.json",
]
intents = discord.Intents.all()
@ -170,7 +170,7 @@ async def on_command_error(ctx, error):
"to run this command in the current channel."
)
elif isinstance(error, commands.CommandInvokeError) and (
"Cannot send messages to this user" in error_text
"Cannot send messages to this user" in error_text
):
return await ctx.send(
f"{ctx.author.mention}: I can't DM you.\n"
@ -198,8 +198,8 @@ async def on_command_error(ctx, error):
# and if said commands get used, add a specific notice.
if ctx.command.name in ಠ_ಠ:
help_text = (
"This probably means that user left (or already got kicked/banned).\n"
+ help_text
"This probably means that user left (or already got kicked/banned).\n"
+ help_text
)
return await ctx.send(
@ -223,7 +223,7 @@ async def on_message(message):
# an allowed command
welcome_allowed = ["reset", "kick", "ban", "warn"]
if message.channel.id == config.welcome_channel and not any(
cmd in message.content for cmd in welcome_allowed
cmd in message.content for cmd in welcome_allowed
):
return

View file

@ -98,7 +98,6 @@ class Err(Cog):
Usage: .serr/.nxerr/.err <Error Code>"""
if self.switch_re.match(err) or err.startswith("0x"): # Switch
if err.startswith("0x"):
err = err[2:]
errcode = int(err, 16)

View file

@ -190,7 +190,8 @@ class Logs(Cog):
# Show a message embed
embed = discord.Embed(description=regd)
embed.set_author(
name=message.author.display_name, icon_url=str(message.author.display_avatar)
name=message.author.display_name,
icon_url=str(message.author.display_avatar),
)
await spy_channel.send(msg, embed=embed)

View file

@ -5,7 +5,13 @@ from discord.ext import commands
from discord.ext.commands import Cog, Context, BucketType
from robocop_ng.helpers.checks import check_if_staff
from robocop_ng.helpers.macros import get_macro, add_macro, edit_macro, remove_macro, get_macros
from robocop_ng.helpers.macros import (
get_macro,
add_macro,
edit_macro,
remove_macro,
get_macros,
)
class Macro(Cog):
@ -20,7 +26,9 @@ class Macro(Cog):
else:
await ctx.send(text)
else:
await ctx.send(f"{ctx.author.mention}: The macro '{key}' doesn't exist.")
await ctx.send(
f"{ctx.author.mention}: The macro '{key}' doesn't exist."
)
@commands.check(check_if_staff)
@commands.command(name="macroadd", aliases=["ma", "addmacro", "add_macro"])
@ -39,9 +47,18 @@ class Macro(Cog):
await ctx.send(f"Error: Macro '{key}' not found.")
@commands.check(check_if_staff)
@commands.command(name="macroremove", aliases=[
"mr", "md", "removemacro", "remove_macro", "macrodel", "delmacro", "delete_macro"
])
@commands.command(
name="macroremove",
aliases=[
"mr",
"md",
"removemacro",
"remove_macro",
"macrodel",
"delmacro",
"delete_macro",
],
)
async def remove_macro(self, ctx: Context, key: str):
if remove_macro(key):
await ctx.send(f"Macro '{key}' removed!")

View file

@ -730,9 +730,7 @@ class Mod(Cog):
avatar_url = str(message.author.display_avatar)
# set the embed message author to original author
embedMessage.set_author(
name=message.author, icon_url=avatar_url
)
embedMessage.set_author(name=message.author, icon_url=avatar_url)
# if message has attachments add them
if message.attachments:
for i in message.attachments:

View file

@ -12,9 +12,13 @@ class RolePersistence(Cog):
async def on_raw_member_remove(self, payload: RawMemberRemoveEvent):
save_roles = []
for role in payload.user.roles:
if role.is_assignable() and \
not role.is_default() and not role.is_premium_subscriber() and \
not role.is_bot_managed() and not role.is_integration():
if (
role.is_assignable()
and not role.is_default()
and not role.is_premium_subscriber()
and not role.is_bot_managed()
and not role.is_integration()
):
save_roles.append(role.id)
if len(save_roles) > 0:
@ -24,9 +28,15 @@ class RolePersistence(Cog):
async def on_member_join(self, member: Member):
user_roles = get_user_roles(member.id)
if len(user_roles) > 0:
user_roles = [member.guild.get_role(int(role)) for role in user_roles
if member.guild.get_role(int(role)) is not None]
await member.add_roles(*user_roles, reason="Restoring old roles from `role_persistence`.")
user_roles = [
member.guild.get_role(int(role))
for role in user_roles
if member.guild.get_role(int(role)) is not None
]
await member.add_roles(
*user_roles, reason="Restoring old roles from `role_persistence`."
)
async def setup(bot):
await bot.add_cog(RolePersistence(bot))

View file

@ -89,7 +89,6 @@ class RyujinxReactionRoles(Cog):
emoji = f"<{emoji}>"
if type(value) is str:
description.append(
f"{emoji} for __{self.emoji_map.get(x).split('(')[1].split(')')[0]}__"
)
@ -126,7 +125,11 @@ class RyujinxReactionRoles(Cog):
if self.get_role_from_emoji(emoji_name) is not None:
role = self.get_role(emoji_name)
if not user in role.members and not user.bot and type(user) is discord.Member:
if (
not user in role.members
and not user.bot
and type(user) is discord.Member
):
await user.add_roles(role)
else:
await self.m.clear_reaction(reaction.emoji)
@ -247,7 +250,6 @@ class RyujinxReactionRoles(Cog):
emoji_name = self.get_emoji_full_name(payload.emoji)
if self.get_role_from_emoji(emoji_name) is not None:
guild = discord.utils.find(
lambda guild: guild.id == payload.guild_id, self.bot.guilds
)