Black formatting

pull/163/head
ASSASSIN0831 4 years ago committed by GitHub
parent bce07f069f
commit 69e2e5acb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ class InfoChannel(Cog):
"channels_channel_id": None, "channels_channel_id": None,
"onlinechannel_id": None, "onlinechannel_id": None,
"offlinechannel_id": None, "offlinechannel_id": None,
"role_ids":{}, "role_ids": {},
"member_count": True, "member_count": True,
"human_count": False, "human_count": False,
"bot_count": False, "bot_count": False,
@ -46,7 +46,7 @@ class InfoChannel(Cog):
"channels_count": False, "channels_count": False,
"online_count": False, "online_count": False,
"offline_count": False, "offline_count": False,
"channel_names":{ "channel_names": {
"category_name": "Server Stats", "category_name": "Server Stats",
"members_channel": "Total Members: {count}", "members_channel": "Total Members: {count}",
"humans_channel": "Humans: {count}", "humans_channel": "Humans: {count}",
@ -55,8 +55,8 @@ class InfoChannel(Cog):
"channels_channel": "Total Channels: {count}", "channels_channel": "Total Channels: {count}",
"online_channel": "Online: {count}", "online_channel": "Online: {count}",
"offline_channel": "Offline:{count}", "offline_channel": "Offline:{count}",
"role_channel": "{role}: {count}" "role_channel": "{role}: {count}",
} },
} }
self.config.register_guild(**default_guild) self.config.register_guild(**default_guild)
@ -113,7 +113,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@commands.group(aliases=['icset']) @commands.group(aliases=["icset"])
@checks.admin() @checks.admin()
async def infochannelset(self, ctx: commands.Context): async def infochannelset(self, ctx: commands.Context):
""" """
@ -242,7 +242,9 @@ class InfoChannel(Cog):
await ctx.send("InfoChannel for offline user count has been disabled.") await ctx.send("InfoChannel for offline user count has been disabled.")
@infochannelset.command(name="rolecount") @infochannelset.command(name="rolecount")
async def _infochannelset_rolecount(self, ctx: commands.Context, role: discord.Role, enabled: bool = None): async def _infochannelset_rolecount(
self, ctx: commands.Context, role: discord.Role, enabled: bool = None
):
""" """
Toggle an infochannel that shows the amount of users in the server with the specified role Toggle an infochannel that shows the amount of users in the server with the specified role
""" """
@ -261,7 +263,7 @@ class InfoChannel(Cog):
else: else:
await ctx.send(f"InfoChannel for {role.name} count has been disabled.") await ctx.send(f"InfoChannel for {role.name} count has been disabled.")
@infochannelset.group(name='name') @infochannelset.group(name="name")
async def channelname(self, ctx: commands.Context): async def channelname(self, ctx: commands.Context):
""" """
Change the name of the infochannels Change the name of the infochannels
@ -269,7 +271,7 @@ class InfoChannel(Cog):
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
pass pass
@channelname.command(name='category') @channelname.command(name="category")
async def _channelname_Category(self, ctx: commands.Context, *, text): async def _channelname_Category(self, ctx: commands.Context, *, text):
""" """
Change the name of the infochannel's category. Change the name of the infochannel's category.
@ -277,12 +279,12 @@ class InfoChannel(Cog):
guild = ctx.message.guild guild = ctx.message.guild
category_id = await self.config.guild(guild).category_id() category_id = await self.config.guild(guild).category_id()
category: discord.CategoryChannel = guild.get_channel(category_id) category: discord.CategoryChannel = guild.get_channel(category_id)
await category.edit(name = text) await category.edit(name=text)
await self.config.guild(guild).channel_names.category_name.set(text) await self.config.guild(guild).channel_names.category_name.set(text)
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='members') @channelname.command(name="members")
async def _channelname_Members(self, ctx: commands.Context, *, text=None): async def _channelname_Members(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the total members infochannel. Change the name of the total members infochannel.
@ -306,7 +308,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='humans') @channelname.command(name="humans")
async def _channelname_Humans(self, ctx: commands.Context, *, text=None): async def _channelname_Humans(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the human users infochannel. Change the name of the human users infochannel.
@ -330,7 +332,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='bots') @channelname.command(name="bots")
async def _channelname_Bots(self, ctx: commands.Context, *, text=None): async def _channelname_Bots(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the bots infochannel. Change the name of the bots infochannel.
@ -354,7 +356,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='roles') @channelname.command(name="roles")
async def _channelname_Roles(self, ctx: commands.Context, *, text=None): async def _channelname_Roles(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the roles infochannel. Change the name of the roles infochannel.
@ -380,7 +382,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='channels') @channelname.command(name="channels")
async def _channelname_Channels(self, ctx: commands.Context, *, text=None): async def _channelname_Channels(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the channels infochannel. Change the name of the channels infochannel.
@ -405,7 +407,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='online') @channelname.command(name="online")
async def _channelname_Online(self, ctx: commands.Context, *, text=None): async def _channelname_Online(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the online infochannel. Change the name of the online infochannel.
@ -429,7 +431,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='offline') @channelname.command(name="offline")
async def _channelname_Offline(self, ctx: commands.Context, *, text=None): async def _channelname_Offline(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the offline infochannel. Change the name of the offline infochannel.
@ -453,7 +455,7 @@ class InfoChannel(Cog):
if not await ctx.tick(): if not await ctx.tick():
await ctx.send("Done!") await ctx.send("Done!")
@channelname.command(name='role') @channelname.command(name="role")
async def _channelname_Role(self, ctx: commands.Context, *, text=None): async def _channelname_Role(self, ctx: commands.Context, *, text=None):
""" """
Change the name of the infochannel for specific roles. Change the name of the infochannel for specific roles.
@ -507,7 +509,7 @@ class InfoChannel(Cog):
"Server Stats", reason="InfoChannel Category make" "Server Stats", reason="InfoChannel Category make"
) )
await self.config.guild(guild).category_id.set(category.id) await self.config.guild(guild).category_id.set(category.id)
await category.edit(position = 0) await category.edit(position=0)
category_id = category.id category_id = category.id
category: discord.CategoryChannel = guild.get_channel(category_id) category: discord.CategoryChannel = guild.get_channel(category_id)
@ -538,7 +540,6 @@ class InfoChannel(Cog):
) )
await self.config.guild(guild).humanchannel_id.set(humanchannel.id) await self.config.guild(guild).humanchannel_id.set(humanchannel.id)
# Remove the old bot channel first # Remove the old bot channel first
botchannel_id = await self.config.guild(guild).botchannel_id() botchannel_id = await self.config.guild(guild).botchannel_id()
if category_id is not None: if category_id is not None:
@ -552,7 +553,6 @@ class InfoChannel(Cog):
) )
await self.config.guild(guild).botchannel_id.set(botchannel.id) await self.config.guild(guild).botchannel_id.set(botchannel.id)
# Remove the old roles channel first # Remove the old roles channel first
roleschannel_id = await self.config.guild(guild).roleschannel_id() roleschannel_id = await self.config.guild(guild).roleschannel_id()
if category_id is not None: if category_id is not None:
@ -567,7 +567,6 @@ class InfoChannel(Cog):
) )
await self.config.guild(guild).roleschannel_id.set(roleschannel.id) await self.config.guild(guild).roleschannel_id.set(roleschannel.id)
# Remove the old channels channel first # Remove the old channels channel first
channels_channel_id = await self.config.guild(guild).channels_channel_id() channels_channel_id = await self.config.guild(guild).channels_channel_id()
if category_id is not None: if category_id is not None:
@ -608,7 +607,7 @@ class InfoChannel(Cog):
await self.config.guild(guild).offlinechannel_id.set(offlinechannel.id) await self.config.guild(guild).offlinechannel_id.set(offlinechannel.id)
async with self.config.guild(guild).role_ids() as role_data: async with self.config.guild(guild).role_ids() as role_data:
#Remove the old role channels first # Remove the old role channels first
for role_id in role_data.keys(): for role_id in role_data.keys():
role_channel_id = role_data[role_id] role_channel_id = role_data[role_id]
if role_channel_id is not None: if role_channel_id is not None:
@ -616,17 +615,17 @@ class InfoChannel(Cog):
if rolechannel: if rolechannel:
await rolechannel.delete(reason="InfoChannel delete") await rolechannel.delete(reason="InfoChannel delete")
#The actual toggle for a role counter # The actual toggle for a role counter
if role: if role:
if str(role.id) in role_data.keys(): if str(role.id) in role_data.keys():
role_data.pop(str(role.id)) #if the role is there, then remove it role_data.pop(str(role.id)) # if the role is there, then remove it
else: else:
role_data[role.id] = None #No channel created yet but we want one to be made role_data[role.id] = None # No channel created yet but we want one to be made
if role_data: if role_data:
# Then create the new ones # Then create the new ones
for role_id in role_data.keys(): for role_id in role_data.keys():
rolechannel = await category.create_voice_channel( rolechannel = await category.create_voice_channel(
str(role_id)+":", reason="InfoChannel rolecount", overwrites=overwrites str(role_id) + ":", reason="InfoChannel rolecount", overwrites=overwrites
) )
role_data[role_id] = rolechannel.id role_data[role_id] = rolechannel.id
@ -693,12 +692,12 @@ class InfoChannel(Cog):
bot_num = len([m for m in guild.members if m.bot]) bot_num = len([m for m in guild.members if m.bot])
# bot_msg = f"Bots: {num}" # bot_msg = f"Bots: {num}"
#Gets count of roles in the server # Gets count of roles in the server
roles_num = len(guild.roles)-1 roles_num = len(guild.roles) - 1
# roles_msg = f"Total Roles: {num}" # roles_msg = f"Total Roles: {num}"
#Gets count of channels in the server # Gets count of channels in the server
#<number of total channels> - <number of channels in the stats category> - <categories> # <number of total channels> - <number of channels in the stats category> - <categories>
channels_num = len(guild.channels) - len(category.voice_channels) - len(guild.categories) channels_num = len(guild.channels) - len(category.voice_channels) - len(guild.categories)
# channels_msg = f"Total Channels: {num}" # channels_msg = f"Total Channels: {num}"
@ -737,31 +736,31 @@ class InfoChannel(Cog):
channel_names = await self.config.guild(guild).channel_names.all() channel_names = await self.config.guild(guild).channel_names.all()
if guild_data["member_count"]: if guild_data["member_count"]:
name = channel_names["members_channel"].format(count = members) name = channel_names["members_channel"].format(count=members)
await channel.edit(reason="InfoChannel update", name=name) await channel.edit(reason="InfoChannel update", name=name)
if humancount: if humancount:
name = channel_names["humans_channel"].format(count = human_num) name = channel_names["humans_channel"].format(count=human_num)
await humanchannel.edit(reason="InfoChannel update", name=name) await humanchannel.edit(reason="InfoChannel update", name=name)
if botcount: if botcount:
name = channel_names["bots_channel"].format(count = bot_num) name = channel_names["bots_channel"].format(count=bot_num)
await botchannel.edit(reason="InfoChannel update", name=name) await botchannel.edit(reason="InfoChannel update", name=name)
if rolescount: if rolescount:
name = channel_names["roles_channel"].format(count = roles_num) name = channel_names["roles_channel"].format(count=roles_num)
await roleschannel.edit(reason="InfoChannel update", name=name) await roleschannel.edit(reason="InfoChannel update", name=name)
if channelscount: if channelscount:
name = channel_names["channels_channel"].format(count = channels_num) name = channel_names["channels_channel"].format(count=channels_num)
await channels_channel.edit(reason="InfoChannel update", name=name) await channels_channel.edit(reason="InfoChannel update", name=name)
if onlinecount: if onlinecount:
name = channel_names["online_channel"].format(count = online_num) name = channel_names["online_channel"].format(count=online_num)
await onlinechannel.edit(reason="InfoChannel update", name=name) await onlinechannel.edit(reason="InfoChannel update", name=name)
if offlinecount: if offlinecount:
name = channel_names["offline_channel"].format(count = offline) name = channel_names["offline_channel"].format(count=offline)
await offlinechannel.edit(reason="InfoChannel update", name=name) await offlinechannel.edit(reason="InfoChannel update", name=name)
async with self.config.guild(guild).role_ids() as role_data: async with self.config.guild(guild).role_ids() as role_data:
@ -772,10 +771,9 @@ class InfoChannel(Cog):
role_num = len(role.members) role_num = len(role.members)
name = channel_names["role_channel"].format(count = role_num, role = role.name) name = channel_names["role_channel"].format(count=role_num, role=role.name)
await rolechannel.edit(reason="InfoChannel update", name=name) await rolechannel.edit(reason="InfoChannel update", name=name)
async def update_infochannel_with_cooldown(self, guild): async def update_infochannel_with_cooldown(self, guild):
"""My attempt at preventing rate limits, lets see how it goes""" """My attempt at preventing rate limits, lets see how it goes"""
if self._critical_section_wooah_: if self._critical_section_wooah_:
@ -861,7 +859,7 @@ class InfoChannel(Cog):
if rolescount: if rolescount:
await self.update_infochannel_with_cooldown(role.guild) await self.update_infochannel_with_cooldown(role.guild)
#delete specific role counter if the role is deleted # delete specific role counter if the role is deleted
async with self.config.guild(role.guild).role_ids() as role_data: async with self.config.guild(role.guild).role_ids() as role_data:
if str(role.id) in role_data.keys(): if str(role.id) in role_data.keys():
role_channel_id = role_data[str(role.id)] role_channel_id = role_data[str(role.id)]

Loading…
Cancel
Save