Skip to content

Commit

Permalink
Big Update: Revamped both tickets, and self roles modules to read dat…
Browse files Browse the repository at this point in the history
…a from config files so updating will be easier. Bug fixes, and alsoupdated other commands to use config.json.
  • Loading branch information
KevinTrinh1227 committed Oct 26, 2023
1 parent ea279ad commit 73bcc7e
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 522 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ user_data.json
__pycache__/

.idea
.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Mod commands require certain permission nodes to execute. View corresponding com
| Bot Feature | Command Usage | Description |
| :--------------------: | :----------------------------------: |:---------------------------------------------------------------------------------------------------------: |
| Force Verification | `/forceverify <@Discord Member> <Hypixel username>` | Force sync a discord member to a Hypixel account |
| Force Unverification | `/forceunverify <@Discord Member>` | Force unsync a discord member to a Hypixel account |
| Force Unverification | `/forceunverify <@Discord Member>` | Force unsync a discord member from a Hypixel account |
| Ban Player | `/ban [@Server Member]` | Ban a player from your server. This punishment will also be logged in a specified channel |
| Kick Player | `/kick [@Server Member]` | Kick a player from your server. This punishment will also be logged in a specified channel |
| Purge Messages | `/purge <Message Amount>` | Clear a specified amount of message in that specific channel |
Expand Down
58 changes: 53 additions & 5 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,61 @@
},
"join_dm_message": {
"title": "Welcome to {guild_name}, {member} (#{member_count})",
"description": "Welcome to the {guild_name}! Verify your account using `/verify [Hypixel Username]`.\n\nMember: {member_mention}\n\n*THIS IS A PLACEHOLDER DM JOIN MESSAGE YOU CAN EDIT THIS IN `~/Hycord-Bot/config.json`* embed_templates section.",
"footer_text": "©️ {guild_name}"
"description": "Welcome to the {guild_name}! Verify your account using `/verify [Hypixel Username]`.\n\nMember: {member_mention}\n\nPlease be sure to read our server rules and if you have any questions, contact a staff member. Enjoy your stay!",
"footer_text": "\u00a9\ufe0f {guild_name}"
},
"server_rules": {
"title": "**DISCORD SERVER RULES**",
"description": "*THIS IS A PLACE HOLDER RULES COMMAND*\n*TO MAKE ANY EDITS GO TO `~/Hycord-Bot/config.json`*\n\n(+) Be respectful and kind to all members.\n(+) No spamming or excessive advertising.\n(+) Use appropriate and safe-for-work content.\n(+) No discrimination or offensive language.\n(+) Respect privacy and don't share personal information without consent.\n(+) Stay on-topic and avoid derailing discussions.\n(+) Follow Discord's terms of service and guidelines.\n(+) No trolling, baiting, or disruptive behavior.\n(+) Respect server staff and their instructions.\n(+) Report issues to server staff.\n(+) No excessive self-promotion or spamming personal links.\n(+) Keep discussions civil and avoid arguments.",
"footer_text": "©️ {guild_name}"
"title": "**🔖 | DISCORD SERVER RULES**",
"description": "(+) Be respectful and kind to all members.\n(+) No spamming or excessive advertising.\n(+) Use appropriate and safe-for-work content.\n(+) No discrimination or offensive language.\n(+) Respect privacy and don't share personal information without consent.\n(+) Stay on-topic and avoid derailing discussions.\n(+) Follow Discord's terms of service and guidelines.\n(+) No trolling, baiting, or disruptive behavior.\n(+) Respect server staff and their instructions.\n(+) Report issues to server staff.\n(+) No excessive self-promotion or spamming personal links.\n(+) Keep discussions civil and avoid arguments.",
"footer_text": "\u00a9\ufe0f {guild_name}"
},
"information": {
"title": "**📌 | Server Information**",
"description": "Welcome to the Community discord server. Be sure to view all of our rules and select our self-roles. Please do not abuse any server bots and members. In order to use our bot please use `/help` to view the bot's commands menu.\n\n**Bot Help Command:** `/help`\n\nFor additional help or information please contact a staff member. Enjoy your stay!",
"footer_text": "\u00a9\ufe0f {guild_name}"
},
"selection_roles": {
"title": "**🔔 | PUBLIC SELF SELECTION ROLES**",
"description": "Use the following buttons below to chose your own personal roles. By clicking the button, you will claim or unclaim the specified role.",
"footer_text": "\u00a9\ufe0f {guild_name}",
"list_of_roles": [
{ "button_label": "🛏️ Bedwars", "role_id": 1166655627708342352 },
{ "button_label": "🗡️ Duels", "role_id": 1166655663162802207 },
{ "button_label": "⚔️ Skywars", "role_id": 1166655647459315743 },
{ "button_label": "🕹️ Arcade", "role_id": 1166855643995590757 }
]
},
"ticket_system": {
"title": "**🎟️ | Ticket Support**",
"description": "Require Support? Click a button below with the corresponding category's emoji and a private channel will be created where our staff team will be ready to assist you!\n\n**Categories**\n🔨 Report a cheater\n🫂 Apply for staff\n📮 Request a role(s)\n🔥 Apply for guild\n🔍 Other\n\nPlease be patient with our team & any ticket abuse will result in a punishment. Note: only 1 ticket can be opened at a time.",
"footer_text": "\u00a9\ufe0f {guild_name}",
"ticket_type_list": [
{
"button_label": "Report a cheater",
"ticket_type": "🔨 | Report a cheater",
"ticket_type_emoji": "🔨"
},
{
"button_label": "Apply for staff",
"ticket_type": "🫂 | Apply for staff",
"ticket_type_emoji": "🫂"
},
{
"button_label": "Request a role(s)",
"ticket_type": "📮 | Request a role(s)",
"ticket_type_emoji": "📮"
},
{
"button_label": "Apply for guild",
"ticket_type": "🔥 | Apply for guild",
"ticket_type_emoji": "🔥"
},
{
"button_label": "Other",
"ticket_type": "🔍 | Other",
"ticket_type_emoji": "🔍"
}
]
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions commands/guild_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from dotenv import load_dotenv
import asyncio
import time
import utils.guild_data as guild


# Open the JSON file and read in the data
with open('config.json') as json_file:
data = json.load(json_file)

Expand All @@ -26,6 +27,7 @@ def __init__(self, client):
@commands.cooldown(1, 20, commands.BucketType.user) # 20 seconds.
async def guildinfo(self, ctx):


try:
hypixel_api_key = os.getenv("HYPIXEL_API_KEY")

Expand Down Expand Up @@ -59,6 +61,7 @@ async def guildinfo(self, ctx):
guild_tag = "No Tag Available"

guild_id = guild_data['_id']
guild_level, current_exp, exp_needed, exp_remaining, total_exp = guild.get_guild_exp_data(total_guild_exp)

total_members = len(guild_data['members'])

Expand All @@ -78,7 +81,10 @@ async def guildinfo(self, ctx):
- **Guild Tag:** [{guild_tag}]
- **Guild ID:** `{guild_id}`
- **Total Members:** `{total_members}`/`125`
- **Total Guild EXP:** {total_guild_exp} experience
- **Total Guild EXP:** {total_guild_exp} EXP
- **Guild Level:** {guild_level}
- **GEXP to Next Level:** `{current_exp}`/`{exp_needed}`
- **GEXP Remaining:** {exp_remaining}
- **Guild Age:** {guild_age:.2f} month(s) old
- **Description:** {guild_description}
- **Stats Link:** [{guild_name} Plancke.io Link]({guild_stats_link})
Expand Down
29 changes: 12 additions & 17 deletions commands/information.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Open the JSON file and read in the data
with open('config.json') as json_file:
data = json.load(json_file)

# Load the "server_rules" template
server_information_template = data["embed_templates"]["information"]

embed_color = int(data["general"]["embed_color"].strip("#"), 16) #convert hex color to hexadecimal format

Expand All @@ -18,27 +21,19 @@ def __init__(self, client):
@commands.has_permissions(administrator = True)
@commands.hybrid_command(aliases=["i", "inform", "info"], brief="information",description="View server information", with_app_command=True)
async def information(self, ctx):
await ctx.channel.purge(limit = 1)
"""
embed1 = discord.Embed(
color = embed_color
)
embed1.set_image(url = "https://imgur.com/iW22uIC.png")
"""

# Replace the footer text with actual values
footer_text = server_information_template["footer_text"].format(
guild_name=ctx.guild.name
)

embed2 = discord.Embed(
description = """
*THIS OUTPUT IS PLACEHOLDER
TO CHANGE PLEASE GO TO "~/Hycord-Bot/commands/information.py"
AND EDIT THE FILE*
Welcome to the discord server discord server. Be sure to view all of our rules and select our self-roles. Please do not abuse any server bots and members. In order to use our bot please use **!help** to view the bot's commands menu.
For any additional help or information please contact a staff member. Enjoy your stay!""",
title=server_information_template["title"],
description = server_information_template["description"],
color = embed_color
)
embed2.timestamp = datetime.datetime.now()
embed2.set_footer(text=f"©️ {ctx.guild.name}", icon_url=ctx.guild.icon.url)
#await ctx.send(embed=embed1)
embed2.set_footer(text=footer_text, icon_url=ctx.guild.icon.url)
await ctx.send(embed=embed2)


Expand Down
Loading

0 comments on commit 73bcc7e

Please sign in to comment.