Skip to content

Commit

Permalink
💯
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed Mar 12, 2024
1 parent bc0e15c commit 357b0c5
Show file tree
Hide file tree
Showing 19 changed files with 176 additions and 176 deletions.
47 changes: 24 additions & 23 deletions Cogs/Configuration/Views/CustomCommandsView.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import discord
import os
from pymongo import MongoClient
from motor.motor_asyncio import AsyncIOMotorClient
from emojis import *
import validators
MONGO_URL = os.getenv('MONGO_URL')

mongo = MongoClient(MONGO_URL)
mongo = AsyncIOMotorClient(MONGO_URL)
db = mongo['astro']
modules = db['Modules']
scollection = db['staffrole']
Expand Down Expand Up @@ -50,7 +50,7 @@ async def callback(self, interaction: discord.Interaction):
try:


commandslogging.update_one(filter, {'$set': data}, upsert=True)
await commandslogging.update_one(filter, {'$set': data}, upsert=True)

await refreshembed(interaction)
await interaction.response.edit_message(content=None)
Expand All @@ -76,7 +76,7 @@ def __init__(self, author):


async def on_submit(self, interaction: discord.Interaction):
amount = customcommands.count_documents({"guild_id": interaction.guild.id})
amount = await customcommands.count_documents({"guild_id": interaction.guild.id})
if amount >= 25:
embed = discord.Embed()
embed.title = f"{redx} {amount}/25"
Expand All @@ -85,7 +85,7 @@ async def on_submit(self, interaction: discord.Interaction):
await interaction.response.edit_message(embed=embed, view=None)

return
result = customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
embed = interaction.message.embeds[0]
if result:
embed = discord.Embed()
Expand All @@ -97,7 +97,7 @@ async def on_submit(self, interaction: discord.Interaction):
name = self.name.value
view = NoEmbeds(self.author, name)
await interaction.response.edit_message(embed=None,content=None, view=view)
customcommands.insert_one({"name": name, "guild_id": interaction.guild.id, "creator": interaction.user.id})
await customcommands.insert_one({"name": name, "guild_id": interaction.guild.id, "creator": interaction.user.id})

class EditCommand(discord.ui.Modal, title='Edit Command'):
def __init__(self, author):
Expand All @@ -117,7 +117,7 @@ def __init__(self, author):


async def on_submit(self, interaction: discord.Interaction):
result = customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
embed = interaction.message.embeds[0]
if result is None:
embed.title = f"{redx} I could not find that."
Expand Down Expand Up @@ -184,7 +184,7 @@ def __init__(self, author):


async def on_submit(self, interaction: discord.Interaction):
result = customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
embed = interaction.message.embeds[0]
if result is None:
embed.title = f"{redx} I could not find that."
Expand Down Expand Up @@ -238,15 +238,15 @@ def __init__(self, author, names):
async def on_submit(self, interaction: discord.Interaction):
colour = self.colour.value.lower()
valid_colours = ['blurple', 'red', 'green', 'grey']
result = customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name.value, "guild_id": interaction.guild.id})
if result is None:
await interaction.response.send_message(f"{no} **{interaction.user.display_name},** I could not find the custom command.")
return

if colour not in valid_colours:
await interaction.response.send_message(f"{redx} **{interaction.user.display_name},** I could not find that colour. (Blurple, Red, Green, Grey)", ephemeral=True)
return
customcommands.update_one({'name': self.names,'guild_id': interaction.guild.id}, {'$set': {'buttons': 'Embed Button', 'cmd': self.name.value, 'button_label': self.label.value, 'colour': self.colour.value, 'emoji': self.emoji.value}})
await customcommands.update_one({'name': self.names,'guild_id': interaction.guild.id}, {'$set': {'buttons': 'Embed Button', 'cmd': self.name.value, 'button_label': self.label.value, 'colour': self.colour.value, 'emoji': self.emoji.value}})
await interaction.response.edit_message(content=f"{tick} **{interaction.user.display_name},** I've set the custom embed button with the command `{self.name.value}`.")

class ButtonURLView(discord.ui.Modal, title='Button URL'):
Expand Down Expand Up @@ -278,7 +278,7 @@ async def on_submit(self, interaction: discord.Interaction):
if not validators.url(url):
await interaction.response.send_message(f"{no} **{interaction.user.display_name},** that is not a valid website url.", ephemeral=True)
return
customcommands.update_one({'name': self.names,'guild_id': interaction.guild.id}, {'$set': {'url': url, 'buttons': 'Link Button', 'button_label': self.label.value}})
await customcommands.update_one({'name': self.names,'guild_id': interaction.guild.id}, {'$set': {'url': url, 'buttons': 'Link Button', 'button_label': self.label.value}})
await interaction.response.edit_message(content=f"{tick} **{interaction.user.display_name},** I've set the buttons to URL with the link `{self.name.value}`.")


Expand All @@ -304,7 +304,7 @@ async def callback(self, interaction: discord.Interaction):
color=discord.Colour.dark_embed())
return await interaction.response.send_message(embed=embed, ephemeral=True)
if color == 'Voting Buttons':
customcommands.update_one({'name': self.name,'guild_id': interaction.guild.id}, {'$set': {'buttons': color}})
await customcommands.update_one({'name': self.name,'guild_id': interaction.guild.id}, {'$set': {'buttons': color}})
await interaction.response.edit_message(content=f"{tick} **{interaction.user.display_name},** I've set the buttons to `{color}`.")
if color == 'Link Button':
await interaction.response.send_modal(ButtonURLView(self.author, self.name))
Expand Down Expand Up @@ -341,11 +341,11 @@ async def callback(self, interaction: discord.Interaction):

if color == 'Enable':
await interaction.response.send_message(content=f"{tick} Enabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'customcommands': True}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'customcommands': True}}, upsert=True)
await refreshembed(interaction)
if color == 'Disable':
await interaction.response.send_message(content=f"{no} Disabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'customcommands': False}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'customcommands': False}}, upsert=True)
await refreshembed(interaction)


Expand Down Expand Up @@ -638,7 +638,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt
color=discord.Colour.dark_embed())
return await interaction.response.send_message(embed=embed, ephemeral=True)

result = customcommands.find_one({"name": self.name, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name, "guild_id": interaction.guild.id})
perm = result.get('permissionroles', None)
if perm is None:
await interaction.response.send_message(content=f"{tick} **{interaction.user.display_name},** please select the required permissions for this command using the `Permission` button!", ephemeral=True)
Expand Down Expand Up @@ -674,7 +674,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt
"content": messagecontent
}

customcommands.update_one({"name": self.name, "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True)
await customcommands.update_one({"name": self.name, "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True)
embed = discord.Embed()
embed.title = f"{greencheck} Success!"
embed.description = f"Start by using </command run:1199462063202902077> and selecting `{self.name}`"
Expand Down Expand Up @@ -798,7 +798,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt
color=discord.Colour.dark_embed())
return await interaction.response.send_message(embed=embed, ephemeral=True)

result = customcommands.find_one({"name": self.name, "guild_id": interaction.guild.id})
result = await customcommands.find_one({"name": self.name, "guild_id": interaction.guild.id})
perm = result.get('permissionroles', None)
if perm is None:
await interaction.response.send_message(content=f"{tick} **{interaction.user.display_name},** please select the required permissions for this command using the `Permission` button!", ephemeral=True)
Expand Down Expand Up @@ -834,7 +834,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt
"content": messagecontent
}

customcommands.update_one({"name": self.name, "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True)
await customcommands.update_one({"name": self.name, "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True)
embed = discord.Embed()
embed.title = f"{greencheck} Success!"
embed.description = f"Start by using </command run:1199462063202902077> and selecting `{self.name}`"
Expand All @@ -858,20 +858,20 @@ async def callback(self, interaction: discord.Interaction):
'permissionroles': selected_role_ids
}

customcommands.update_one({'name': self.name, 'guild_id': interaction.guild.id}, {'$set': data}, upsert=True)
await customcommands.update_one({'name': self.name, 'guild_id': interaction.guild.id}, {'$set': data}, upsert=True)
await interaction.response.edit_message(content=f"{tick} **{interaction.user.display_name},** I've set the permission requirement.", view=None)


async def refreshembed(interaction):
commands = customcommands.find({'guild_id': interaction.guild.id})
moduledata = modules.find_one({'guild_id': interaction.guild.id})
moduledata = await modules.find_one({'guild_id': interaction.guild.id})
modulemsg = 'False'
if moduledata:
modulemsg = moduledata.get('customcommands', 'False')



logging = commandslogging.find_one({'guild_id': interaction.guild.id})
logging = await commandslogging.find_one({'guild_id': interaction.guild.id})
loggingmsg = "Not Configured"
if logging:
loggingid = logging['channel_id']
Expand All @@ -880,8 +880,9 @@ async def refreshembed(interaction):




amount = customcommands.count_documents({'guild_id': interaction.guild.id})

amount = await customcommands.count_documents({'guild_id': interaction.guild.id})
commands = await commands.to_list(length=amount)
embed = discord.Embed(title=f"<:command1:1199456319363633192> Custom Commands ({amount}/25)", description="", color=discord.Color.dark_embed())
embed.set_thumbnail(url=interaction.guild.icon)
embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon)
Expand Down
10 changes: 5 additions & 5 deletions Cogs/Configuration/Views/Customationview.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import discord
import os
from pymongo import MongoClient
from motor.motor_asyncio import AsyncIOMotorClient
from emojis import *
MONGO_URL = os.getenv('MONGO_URL')
client = MongoClient(MONGO_URL)
client = AsyncIOMotorClient(MONGO_URL)
db = client['astro']
scollection = db['staffrole']
Customisation = db['Customisation']
Expand Down Expand Up @@ -36,15 +36,15 @@ async def callback(self, interaction: discord.Interaction):
if result is None:
await interaction.response.send_message(f"{tick} There are no embeds to reset.", ephemeral=True)
return
Customisation.delete_one({"guild_id": interaction.guild.id, "type": "Promotions"})
await Customisation.delete_one({"guild_id": interaction.guild.id, "type": "Promotions"})
await interaction.response.send_message(f"{tick} **{interaction.user.display_name}**, promotions embed have been reset.", ephemeral=True)

if color == "Infractions":
result = Customisation.find_one({"guild_id": interaction.guild.id, "type": "Infractions"})
if result is None:
await interaction.response.send_message(f"{tick} There are no embeds to reset.", ephemeral=True)
return
Customisation.delete_one({"guild_id": interaction.guild.id, "type": "Infractions"})
await Customisation.delete_one({"guild_id": interaction.guild.id, "type": "Infractions"})
await interaction.response.send_message(f"{tick} **{interaction.user.display_name}**, infractions embed have been reset.", ephemeral=True)


Expand Down Expand Up @@ -355,6 +355,6 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt
"image": embed.image.url if embed.image else None,
"guild_id": interaction.guild.id
}
Customisation.update_one(filter, {"$set": embed_data}, upsert=True)
await Customisation.update_one(filter, {"$set": embed_data}, upsert=True)
embed = discord.Embed(title=f"{greencheck} Customisation Saved", description="Your embed has been saved." ,color=discord.Colour.brand_green())
await interaction.response.edit_message(content=None, embed=embed, view=None)
10 changes: 5 additions & 5 deletions Cogs/Configuration/Views/Utilityview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import discord
import os
from pymongo import MongoClient
from motor.motor_asyncio import AsyncIOMotorClient
from emojis import *
MONGO_URL = os.getenv('MONGO_URL')

mongo = MongoClient(MONGO_URL)
mongo = AsyncIOMotorClient(MONGO_URL)
db = mongo['astro']
modules = db['Modules']

Expand Down Expand Up @@ -32,15 +32,15 @@ async def callback(self, interaction: discord.Interaction):

if color == 'Enable':
await interaction.response.send_message(content=f"{tick} Enabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Utility': True}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Utility': True}}, upsert=True)
await refreshembed(interaction)
if color == 'Disable':
await interaction.response.send_message(content=f"{no} Disabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Utility': False}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Utility': False}}, upsert=True)
await refreshembed(interaction)

async def refreshembed(interaction):
moduleddata = modules.find_one({'guild_id': interaction.guild.id})
moduleddata = await modules.find_one({'guild_id': interaction.guild.id})
modulemsg = "True"
if moduleddata:
modulemsg = f"{moduleddata['Utility']}"
Expand Down
22 changes: 11 additions & 11 deletions Cogs/Configuration/Views/applicationsview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import discord
import os
from pymongo import MongoClient
from motor.motor_asyncio import AsyncIOMotorClient
from emojis import *
MONGO_URL = os.getenv('MONGO_URL')

mongo = MongoClient(MONGO_URL)
mongo = AsyncIOMotorClient(MONGO_URL)
db = mongo['astro']
modules = db['Modules']
scollection = db['staffrole']
Expand Down Expand Up @@ -46,12 +46,12 @@ async def callback(self, interaction: discord.Interaction):

if color == 'Enable':
await interaction.response.send_message(content=f"{tick} Enabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Applications': True}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Applications': True}}, upsert=True)
await refreshembed(interaction)

if color == 'Disable':
await interaction.response.send_message(content=f"{no} Disabled", ephemeral=True)
modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Applications': False}}, upsert=True)
await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Applications': False}}, upsert=True)
await refreshembed(interaction)

class ApplicationChannel(discord.ui.ChannelSelect):
Expand All @@ -76,12 +76,12 @@ async def callback(self, interaction: discord.Interaction):
}

try:
existing_record = ApplicationsChannel.find_one(filter)
existing_record = await ApplicationsChannel.find_one(filter)

if existing_record:
ApplicationsChannel.update_one(filter, {'$set': data})
await ApplicationsChannel.update_one(filter, {'$set': data})
else:
ApplicationsChannel.insert_one(data)
await ApplicationsChannel.insert_one(data)

await interaction.response.edit_message(content=None)
await refreshembed(interaction)
Expand All @@ -108,16 +108,16 @@ async def callback(self, interaction: discord.Interaction):
}


ApplicationsRolesDB.update_one({'guild_id': interaction.guild.id}, {'$set': data}, upsert=True)
await ApplicationsRolesDB.update_one({'guild_id': interaction.guild.id}, {'$set': data}, upsert=True)
await interaction.response.edit_message(content=None)
await refreshembed(interaction)
print(f"Select Application Roles: {selected_role_ids}")


async def refreshembed(interaction):
applicationchannelresult = ApplicationsChannel.find_one({'guild_id': interaction.guild.id})
staffroleresult = ApplicationsRolesDB.find_one({'guild_id': interaction.guild.id})
moduleddata = modules.find_one({'guild_id': interaction.guild.id})
applicationchannelresult = await ApplicationsChannel.find_one({'guild_id': interaction.guild.id})
staffroleresult = await ApplicationsRolesDB.find_one({'guild_id': interaction.guild.id})
moduleddata = await modules.find_one({'guild_id': interaction.guild.id})

approlemsg = "Not Configured"
appchannelmsg = "Not Configured"
Expand Down
Loading

0 comments on commit 357b0c5

Please sign in to comment.