-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d1d814
commit a21c9c6
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .serverassistnat import ServerAssistant | ||
|
||
async def setup(bot): | ||
await bot.add_cog(ServerAssistant(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"author": [ | ||
"nottherealtar" | ||
], | ||
"install_msg": "`[p]serverassistant help`", | ||
"name": "ServerAssistant", | ||
"short": "Lets help organize your server!", | ||
"description": "ServerAssistant is a cog that helps you organize your server by providing useful commands for managing channels; colourizing them in a rainbow order, generating mind maps of the channels structures etc.", | ||
"min_bot_version": "3.5.0", | ||
"tags": [ | ||
"util", | ||
"admin", | ||
"channels" | ||
], | ||
"end_user_data_statement": "This cog does not persistently store any data or metadata about users.", | ||
"type": "COG" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from redbot.core import commands, Config | ||
import discord | ||
|
||
class ServerAssistant(commands.Cog): | ||
"""A cog for organizing your Discord server.""" | ||
|
||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
@commands.group() | ||
async def serverassistant(self, ctx): | ||
"""Base command for the ServerAssistant cog.""" | ||
if ctx.invoked_subcommand is None: | ||
await ctx.send_help(str(ctx.command)) | ||
|
||
@serverassistant.command(name="help") | ||
async def _help(self, ctx): | ||
"""Displays the help diagram for ServerAssistant commands.""" | ||
help_message = discord.Embed(title="ServerAssistant Commands", description="Helpful commands for managing your Discord server.", color=0x00ff00) | ||
help_message.add_field(name="[P]serverassistant createcolorroles", value="Create a set of predefined color roles.", inline=False) | ||
help_message.add_field(name="[P]serverassistant selectcolorrole", value="Select a color for your role (requires interaction support).", inline=False) | ||
help_message.add_field(name="[P]serverassistant channelmap", value="Generate a mind map of your server's channels.", inline=False) | ||
await ctx.send(embed=help_message) | ||
|
||
@serverassistant.command(name="createcolorroles") | ||
async def create_color_roles(self, ctx): | ||
"""Create a set of predefined color roles.""" | ||
colors = { | ||
"Red": discord.Color.red(), | ||
"Green": discord.Color.green(), | ||
"Blue": discord.Color.blue(), | ||
"Yellow": discord.Color.gold(), | ||
"Purple": discord.Color.purple(), | ||
"Orange": discord.Color.orange(), | ||
"Pink": discord.Color.magenta(), | ||
"Teal": discord.Color.teal(), | ||
"Cyan": discord.Color.blue(), | ||
"White": discord.Color.from_rgb(255, 255, 255), | ||
"Black": discord.Color.from_rgb(0, 0, 0), | ||
# Add more colors as needed | ||
} | ||
for color_name, color in colors.items(): | ||
if discord.utils.get(ctx.guild.roles, name=color_name): | ||
await ctx.send(f"Role `{color_name}` already exists.") | ||
else: | ||
await ctx.guild.create_role(name=color_name, color=color) | ||
await ctx.send(f"Role `{color_name}` created.") | ||
|
||
@serverassistant.command(name="selectcolorrole") | ||
async def select_color_role(self, ctx): | ||
"""Send an embed with a dropdown for selecting a color role.""" | ||
# This is a conceptual outline. Actual implementation depends on your Discord library version and its support for interactions. | ||
await ctx.send("This feature requires interaction support from your Discord library. Please refer to the documentation for implementing dropdowns and handling interactions.") | ||
|
||
@serverassistant.command(name="channelmap") | ||
async def channel_map(self, ctx): | ||
"""Generate a mind map of the server's channels.""" | ||
channel_list = ctx.guild.channels # Fetch all channels | ||
channel_list.sort(key=lambda x: (x.position, x.type)) # Sort channels by position and type | ||
|
||
tree_string = "Server Channel Structure:\n" | ||
for channel in channel_list: | ||
if isinstance(channel, discord.CategoryChannel): | ||
tree_string += f"📁 {channel.name}\n" | ||
for sub_channel in channel.channels: | ||
tree_string += f" ├ {sub_channel.name}\n" | ||
elif isinstance(channel, discord.TextChannel) and channel.category is None: | ||
tree_string += f"📄 {channel.name}\n" | ||
elif isinstance(channel, discord.VoiceChannel) and channel.category is None: | ||
tree_string += f"🔊 {channel.name}\n" | ||
|
||
# Ensure the message does not exceed Discord's max message length (2000 characters) | ||
if len(tree_string) > 2000: | ||
await ctx.send("The server structure is too large to display in one message. Consider breaking it down.") | ||
else: | ||
await ctx.send(f"```{tree_string}```") | ||
|
||
def setup(bot): | ||
bot.add_cog(ServerAssistant(bot)) |