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:
parent
9caa1f6b72
commit
5e2ce2abaa
8 changed files with 61 additions and 24 deletions
10
.github/workflows/formatting.yml
vendored
10
.github/workflows/formatting.yml
vendored
|
@ -12,6 +12,7 @@ jobs:
|
||||||
black:
|
black:
|
||||||
name: Python Black
|
name: Python Black
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
@ -47,3 +48,12 @@ jobs:
|
||||||
git commit -m "Apply black formatting"
|
git commit -m "Apply black formatting"
|
||||||
git push
|
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
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ wanted_jsons = [
|
||||||
"data/userlog.json",
|
"data/userlog.json",
|
||||||
"data/invites.json",
|
"data/invites.json",
|
||||||
"data/macros.json",
|
"data/macros.json",
|
||||||
"data/persistent_roles.json"
|
"data/persistent_roles.json",
|
||||||
]
|
]
|
||||||
|
|
||||||
intents = discord.Intents.all()
|
intents = discord.Intents.all()
|
||||||
|
|
|
@ -98,7 +98,6 @@ class Err(Cog):
|
||||||
Usage: .serr/.nxerr/.err <Error Code>"""
|
Usage: .serr/.nxerr/.err <Error Code>"""
|
||||||
|
|
||||||
if self.switch_re.match(err) or err.startswith("0x"): # Switch
|
if self.switch_re.match(err) or err.startswith("0x"): # Switch
|
||||||
|
|
||||||
if err.startswith("0x"):
|
if err.startswith("0x"):
|
||||||
err = err[2:]
|
err = err[2:]
|
||||||
errcode = int(err, 16)
|
errcode = int(err, 16)
|
||||||
|
|
|
@ -190,7 +190,8 @@ class Logs(Cog):
|
||||||
# Show a message embed
|
# Show a message embed
|
||||||
embed = discord.Embed(description=regd)
|
embed = discord.Embed(description=regd)
|
||||||
embed.set_author(
|
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)
|
await spy_channel.send(msg, embed=embed)
|
||||||
|
|
|
@ -5,7 +5,13 @@ from discord.ext import commands
|
||||||
from discord.ext.commands import Cog, Context, BucketType
|
from discord.ext.commands import Cog, Context, BucketType
|
||||||
|
|
||||||
from robocop_ng.helpers.checks import check_if_staff
|
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):
|
class Macro(Cog):
|
||||||
|
@ -20,7 +26,9 @@ class Macro(Cog):
|
||||||
else:
|
else:
|
||||||
await ctx.send(text)
|
await ctx.send(text)
|
||||||
else:
|
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.check(check_if_staff)
|
||||||
@commands.command(name="macroadd", aliases=["ma", "addmacro", "add_macro"])
|
@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.")
|
await ctx.send(f"Error: Macro '{key}' not found.")
|
||||||
|
|
||||||
@commands.check(check_if_staff)
|
@commands.check(check_if_staff)
|
||||||
@commands.command(name="macroremove", aliases=[
|
@commands.command(
|
||||||
"mr", "md", "removemacro", "remove_macro", "macrodel", "delmacro", "delete_macro"
|
name="macroremove",
|
||||||
])
|
aliases=[
|
||||||
|
"mr",
|
||||||
|
"md",
|
||||||
|
"removemacro",
|
||||||
|
"remove_macro",
|
||||||
|
"macrodel",
|
||||||
|
"delmacro",
|
||||||
|
"delete_macro",
|
||||||
|
],
|
||||||
|
)
|
||||||
async def remove_macro(self, ctx: Context, key: str):
|
async def remove_macro(self, ctx: Context, key: str):
|
||||||
if remove_macro(key):
|
if remove_macro(key):
|
||||||
await ctx.send(f"Macro '{key}' removed!")
|
await ctx.send(f"Macro '{key}' removed!")
|
||||||
|
|
|
@ -730,9 +730,7 @@ class Mod(Cog):
|
||||||
avatar_url = str(message.author.display_avatar)
|
avatar_url = str(message.author.display_avatar)
|
||||||
|
|
||||||
# set the embed message author to original author
|
# set the embed message author to original author
|
||||||
embedMessage.set_author(
|
embedMessage.set_author(name=message.author, icon_url=avatar_url)
|
||||||
name=message.author, icon_url=avatar_url
|
|
||||||
)
|
|
||||||
# if message has attachments add them
|
# if message has attachments add them
|
||||||
if message.attachments:
|
if message.attachments:
|
||||||
for i in message.attachments:
|
for i in message.attachments:
|
||||||
|
|
|
@ -12,9 +12,13 @@ class RolePersistence(Cog):
|
||||||
async def on_raw_member_remove(self, payload: RawMemberRemoveEvent):
|
async def on_raw_member_remove(self, payload: RawMemberRemoveEvent):
|
||||||
save_roles = []
|
save_roles = []
|
||||||
for role in payload.user.roles:
|
for role in payload.user.roles:
|
||||||
if role.is_assignable() and \
|
if (
|
||||||
not role.is_default() and not role.is_premium_subscriber() and \
|
role.is_assignable()
|
||||||
not role.is_bot_managed() and not role.is_integration():
|
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)
|
save_roles.append(role.id)
|
||||||
|
|
||||||
if len(save_roles) > 0:
|
if len(save_roles) > 0:
|
||||||
|
@ -24,9 +28,15 @@ class RolePersistence(Cog):
|
||||||
async def on_member_join(self, member: Member):
|
async def on_member_join(self, member: Member):
|
||||||
user_roles = get_user_roles(member.id)
|
user_roles = get_user_roles(member.id)
|
||||||
if len(user_roles) > 0:
|
if len(user_roles) > 0:
|
||||||
user_roles = [member.guild.get_role(int(role)) for role in user_roles
|
user_roles = [
|
||||||
if member.guild.get_role(int(role)) is not None]
|
member.guild.get_role(int(role))
|
||||||
await member.add_roles(*user_roles, reason="Restoring old roles from `role_persistence`.")
|
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):
|
async def setup(bot):
|
||||||
await bot.add_cog(RolePersistence(bot))
|
await bot.add_cog(RolePersistence(bot))
|
||||||
|
|
|
@ -89,7 +89,6 @@ class RyujinxReactionRoles(Cog):
|
||||||
emoji = f"<{emoji}>"
|
emoji = f"<{emoji}>"
|
||||||
|
|
||||||
if type(value) is str:
|
if type(value) is str:
|
||||||
|
|
||||||
description.append(
|
description.append(
|
||||||
f"{emoji} for __{self.emoji_map.get(x).split('(')[1].split(')')[0]}__"
|
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:
|
if self.get_role_from_emoji(emoji_name) is not None:
|
||||||
role = self.get_role(emoji_name)
|
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)
|
await user.add_roles(role)
|
||||||
else:
|
else:
|
||||||
await self.m.clear_reaction(reaction.emoji)
|
await self.m.clear_reaction(reaction.emoji)
|
||||||
|
@ -247,7 +250,6 @@ class RyujinxReactionRoles(Cog):
|
||||||
emoji_name = self.get_emoji_full_name(payload.emoji)
|
emoji_name = self.get_emoji_full_name(payload.emoji)
|
||||||
|
|
||||||
if self.get_role_from_emoji(emoji_name) is not None:
|
if self.get_role_from_emoji(emoji_name) is not None:
|
||||||
|
|
||||||
guild = discord.utils.find(
|
guild = discord.utils.find(
|
||||||
lambda guild: guild.id == payload.guild_id, self.bot.guilds
|
lambda guild: guild.id == payload.guild_id, self.bot.guilds
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue