diff --git a/Cogs/Configuration/Views/CustomCommandsView.py b/Cogs/Configuration/Views/CustomCommandsView.py index 0c7f0c36..003432a9 100644 --- a/Cogs/Configuration/Views/CustomCommandsView.py +++ b/Cogs/Configuration/Views/CustomCommandsView.py @@ -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'] @@ -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) @@ -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" @@ -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() @@ -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): @@ -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." @@ -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." @@ -238,7 +238,7 @@ 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 @@ -246,7 +246,7 @@ async def on_submit(self, interaction: discord.Interaction): 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'): @@ -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}`.") @@ -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)) @@ -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) @@ -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) @@ -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 and selecting `{self.name}`" @@ -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) @@ -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 and selecting `{self.name}`" @@ -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'] @@ -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) diff --git a/Cogs/Configuration/Views/Customationview.py b/Cogs/Configuration/Views/Customationview.py index fe867893..050bcdcd 100644 --- a/Cogs/Configuration/Views/Customationview.py +++ b/Cogs/Configuration/Views/Customationview.py @@ -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'] @@ -36,7 +36,7 @@ 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": @@ -44,7 +44,7 @@ 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": "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) @@ -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) \ No newline at end of file diff --git a/Cogs/Configuration/Views/Utilityview.py b/Cogs/Configuration/Views/Utilityview.py index 42689db0..104c2448 100644 --- a/Cogs/Configuration/Views/Utilityview.py +++ b/Cogs/Configuration/Views/Utilityview.py @@ -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'] @@ -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']}" diff --git a/Cogs/Configuration/Views/applicationsview.py b/Cogs/Configuration/Views/applicationsview.py index 5d56bc9e..5ab04925 100644 --- a/Cogs/Configuration/Views/applicationsview.py +++ b/Cogs/Configuration/Views/applicationsview.py @@ -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'] @@ -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): @@ -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) @@ -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" diff --git a/Cogs/Configuration/Views/connectionrolesview.py b/Cogs/Configuration/Views/connectionrolesview.py index ece77c4b..00fb9c98 100644 --- a/Cogs/Configuration/Views/connectionrolesview.py +++ b/Cogs/Configuration/Views/connectionrolesview.py @@ -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'] @@ -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': {'Connection': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Connection': 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': {'Connection': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Connection': 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 = moduleddata.get('Connection', 'False') diff --git a/Cogs/Configuration/Views/feedbackview.py b/Cogs/Configuration/Views/feedbackview.py index 4b920ac4..e52ee3e4 100644 --- a/Cogs/Configuration/Views/feedbackview.py +++ b/Cogs/Configuration/Views/feedbackview.py @@ -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'] @@ -44,12 +44,12 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = feedbackch.find_one(filter) + existing_record = await feedbackch.find_one(filter) if existing_record: - feedbackch.update_one(filter, {'$set': data}) + await feedbackch.update_one(filter, {'$set': data}) else: - feedbackch.insert_one(data) + await feedbackch.insert_one(data) await interaction.response.edit_message(content=None) await refreshembed(interaction) except Exception as e: @@ -80,17 +80,17 @@ 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': {'Feedback': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Feedback': 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': {'Feedback': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Feedback': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - feedbackchannelresult = feedbackch.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + feedbackchannelresult = await feedbackch.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" feedbackchannelmsg = "Not Configured" if moduleddata: @@ -103,7 +103,7 @@ async def refreshembed(interaction): else: feedbackchannelmsg = channel.mention embed = discord.Embed(title="<:Rate:1162135093129785364> Staff Feedback Module", color=discord.Color.dark_embed()) - embed.add_field(name="<:settings:1207368347931516928> Staff Feedback Configuration", value=f"{replytop}**Enabled:** {modulemsg}\n{replybottom} {feedbackchannelmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) + embed.add_field(name="<:settings:1207368347931516928> Staff Feedback Configuration", value=f"{replytop}**Enabled:** {modulemsg}\n{replybottom}**Feedback Channel:** {feedbackchannelmsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", inline=False) embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) try: diff --git a/Cogs/Configuration/Views/forumsview.py b/Cogs/Configuration/Views/forumsview.py index caf66734..b0cf91fc 100644 --- a/Cogs/Configuration/Views/forumsview.py +++ b/Cogs/Configuration/Views/forumsview.py @@ -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'] @@ -46,15 +46,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': {'Forums': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Forums': 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': {'Forums': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Forums': 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['Forums']}" diff --git a/Cogs/Configuration/Views/infractionsview.py b/Cogs/Configuration/Views/infractionsview.py index f491330d..98c84bb2 100644 --- a/Cogs/Configuration/Views/infractionsview.py +++ b/Cogs/Configuration/Views/infractionsview.py @@ -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'] @@ -45,12 +45,12 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = infchannel.find_one(filter) + existing_record = await infchannel.find_one(filter) if existing_record: - infchannel.update_one(filter, {'$set': data}) + await infchannel.update_one(filter, {'$set': data}) else: - infchannel.insert_one(data) + await infchannel.insert_one(data) await refreshembed(self, interaction) await interaction.response.edit_message(content=None) except Exception as e: @@ -81,11 +81,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': {'infractions': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'infractions': True}}, upsert=True) await refreshembed(self, interaction) if color == 'Disable': await interaction.response.send_message(content=f"{no} Disabled", ephemeral=True) - modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'infractions': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'infractions': False}}, upsert=True) await refreshembed(self, interaction) class InfractionTypes(discord.ui.Select): def __init__(self, author): @@ -133,8 +133,8 @@ async def on_submit(self, interaction: discord.Interaction): 'types': {'$in': [type_value]} } - types = nfractiontypes.find_one(filterm) - infractiontypesresult = nfractiontypes.find_one({'guild_id': interaction.guild.id}) + types = await nfractiontypes.find_one(filterm) + infractiontypesresult = await nfractiontypes.find_one({'guild_id': interaction.guild.id}) infractiontypescount = len(infractiontypesresult['types']) if infractiontypescount >= 15: @@ -144,7 +144,7 @@ async def on_submit(self, interaction: discord.Interaction): - nfractiontypes.update_one( + await nfractiontypes.update_one( {'guild_id': interaction.guild.id}, {'$addToSet': {'types': type_value}}, upsert=True @@ -172,11 +172,11 @@ async def on_submit(self, interaction: discord.Interaction): 'types': {'$in': [type_value]} } - types = nfractiontypes.find_one(filterm) + types = await nfractiontypes.find_one(filterm) if types is None: return await interaction.response.send_message(content=f"{no} **{interaction.user.display_name}**, Infraction type not found.", ephemeral=True) - nfractiontypes.update_one( + await nfractiontypes.update_one( {'guild_id': interaction.guild.id}, {'$pull': {'types': type_value}}, upsert=True @@ -186,12 +186,12 @@ async def on_submit(self, interaction: discord.Interaction): await interaction.response.send_message(content=f"{tick} **{interaction.user.display_name}**, Infraction type deleted successfully", ephemeral=True) await refreshembed(self, interaction) async def refreshembed(self, interaction): - infractionchannelresult = infchannel.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + infractionchannelresult = await infchannel.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" infchannelmsg = "Not Configured" infractiontypess = "Activity Notice, Verbal Warning, Warning, Strike, Demotion, Termination" - infractiontyperesult = nfractiontypes.find_one({'guild_id': interaction.guild.id}) + infractiontyperesult = await nfractiontypes.find_one({'guild_id': interaction.guild.id}) if infractiontyperesult: infractiontypess = infractiontyperesult['types'] infractiontypess = ', '.join(infractiontypess) diff --git a/Cogs/Configuration/Views/loaview.py b/Cogs/Configuration/Views/loaview.py index a14a7386..889ffffe 100644 --- a/Cogs/Configuration/Views/loaview.py +++ b/Cogs/Configuration/Views/loaview.py @@ -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'] @@ -47,10 +47,10 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = loachannel.find_one(filter) + existing_record = await loachannel.find_one(filter) if existing_record: - loachannel.update_one(filter, {'$set': data}) + await loachannel.update_one(filter, {'$set': data}) else: loachannel.insert_one(data) await interaction.response.edit_message(content=None) @@ -84,9 +84,9 @@ async def callback(self, interaction: discord.Interaction): existing_record = LOARole.find_one(filter) if existing_record: - LOARole.update_one(filter, {'$set': data}) + await LOARole.update_one(filter, {'$set': data}) else: - LOARole.insert_one(data) + await LOARole.insert_one(data) await interaction.response.edit_message(content=None) await refreshembed(interaction) except Exception as e: @@ -117,18 +117,18 @@ 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': {'LOA': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'LOA': 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': {'LOA': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'LOA': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - loachannelresult = loachannel.find_one({'guild_id': interaction.guild.id}) - loaroleresult = LOARole.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + loachannelresult = await loachannel.find_one({'guild_id': interaction.guild.id}) + loaroleresult = await LOARole.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" loarolemsg = "Not Configured" loachannelmsg = "Not Configured" diff --git a/Cogs/Configuration/Views/modmailview.py b/Cogs/Configuration/Views/modmailview.py index 234f29b7..5309b81f 100644 --- a/Cogs/Configuration/Views/modmailview.py +++ b/Cogs/Configuration/Views/modmailview.py @@ -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'] @@ -23,6 +23,7 @@ modmailcategory = db['modmailcategory'] modmailping = db['modmailping'] transcriptschannel = db['transcriptschannel'] + class ModmailCategory(discord.ui.ChannelSelect): def __init__(self, author): super().__init__(placeholder='Modmail Category', channel_types=[discord.ChannelType.category]) @@ -48,9 +49,9 @@ async def callback(self, interaction: discord.Interaction): existing_record = modmailcategory.find_one(filter) if existing_record: - modmailcategory.update_one(filter, {'$set': data}) + await modmailcategory.update_one(filter, {'$set': data}) else: - modmailcategory.insert_one(data) + await modmailcategory.insert_one(data) await interaction.response.edit_message(content=None) await refreshembed(interaction) except Exception as e: @@ -80,12 +81,12 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = transcriptschannel.find_one(filter) + existing_record = await transcriptschannel.find_one(filter) if existing_record: - transcriptschannel.update_one(filter, {'$set': data}) + await transcriptschannel.update_one(filter, {'$set': data}) else: - transcriptschannel.insert_one(data) + await transcriptschannel.insert_one(data) await interaction.response.edit_message(content=None) await refreshembed(interaction) except Exception as e: @@ -116,11 +117,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': {'Modmail': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Modmail': 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': {'Modmail': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Modmail': False}}, upsert=True) await refreshembed(interaction) class ModmailPing(discord.ui.RoleSelect): @@ -141,21 +142,20 @@ async def callback(self, interaction: discord.Interaction): } - modmailping.update_one({'guild_id': interaction.guild.id}, {'$set': data}, upsert=True) + await modmailping.update_one({'guild_id': interaction.guild.id}, {'$set': data}, upsert=True) await interaction.response.edit_message(content=None) await refreshembed(interaction) async def refreshembed(interaction): - transcriptschannelresult = transcriptschannel.find_one({'guild_id': interaction.guild.id}) - modmailcategoryresult = modmailcategory.find_one({'guild_id': interaction.guild.id}) + transcriptschannelresult = await transcriptschannel.find_one({'guild_id': interaction.guild.id}) + modmailcategoryresult = await modmailcategory.find_one({'guild_id': interaction.guild.id}) transcriptschannels = "Not Configured" modmailcategorys = "Not Configured" - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" - suggestionchannelmsg = "Not Configured" if moduleddata: modulemsg = moduleddata.get('Modmail', 'False') - modmailpingresult = modmailping.find_one({'guild_id': interaction.guild.id}) + modmailpingresult = await modmailping.find_one({'guild_id': interaction.guild.id}) modmailroles = "Not Configured" if modmailpingresult: modmailroles = [f'<@&{roleid}>' for sublist in modmailpingresult['modmailping'] for roleid in sublist if interaction.guild.get_role(roleid) is not None] @@ -168,7 +168,7 @@ async def refreshembed(interaction): if modmailcategoryresult: modmailcategorys = f"<#{modmailcategoryresult['category_id']}>" embed = discord.Embed(title="<:messagereceived:1201999712593383444> Modmail", color=discord.Color.dark_embed()) - embed.add_field(name="<:settings:1207368347931516928> Modmail Configuration", value=f"{replytop}**Enabled:** {modulemsg}\n{replymiddle}**Modmail Category:** {modmailcategorys}\n{replymiddle}**Modmail Pings:** {modmailroles}\n{replybottom}** {transcriptschannels}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)") + embed.add_field(name="<:settings:1207368347931516928> Modmail Configuration", value=f"{replytop}**Enabled:** {modulemsg}\n{replymiddle}**Modmail Category:** {modmailcategorys}\n{replymiddle}**Modmail Pings:** {modmailroles}\n{replybottom}**Transcript Channel** {transcriptschannels}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)") embed.set_thumbnail(url=interaction.guild.icon) embed.set_author(name=interaction.guild.name, icon_url=interaction.guild.icon) try: diff --git a/Cogs/Configuration/Views/partnershipsview.py b/Cogs/Configuration/Views/partnershipsview.py index cb5713e3..574a1fea 100644 --- a/Cogs/Configuration/Views/partnershipsview.py +++ b/Cogs/Configuration/Views/partnershipsview.py @@ -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'] @@ -45,9 +45,9 @@ async def callback(self, interaction: discord.Interaction): existing_record = partnershipsch.find_one(filter) if existing_record: - partnershipsch.update_one(filter, {'$set': data}) + await partnershipsch.update_one(filter, {'$set': data}) else: - partnershipsch.insert_one(data) + await partnershipsch.insert_one(data) await refreshembed(interaction) await interaction.response.edit_message(content=None) except Exception as e: @@ -78,17 +78,17 @@ 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': {'Partnerships': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Partnerships': 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': {'Partnerships': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Partnerships': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - partnershipchannelresult = partnershipsch.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + partnershipchannelresult = await partnershipsch.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" partnershipchannelmsg = "Not Configured" if moduleddata: diff --git a/Cogs/Configuration/Views/promotionsview.py b/Cogs/Configuration/Views/promotionsview.py index 94ccd839..ece7474b 100644 --- a/Cogs/Configuration/Views/promotionsview.py +++ b/Cogs/Configuration/Views/promotionsview.py @@ -1,10 +1,9 @@ import discord import os -from pymongo import MongoClient from emojis import * MONGO_URL = os.getenv('MONGO_URL') - -mongo = MongoClient(MONGO_URL) +from motor.motor_asyncio import AsyncIOMotorClient +mongo = AsyncIOMotorClient(MONGO_URL) db = mongo['astro'] modules = db['Modules'] scollection = db['staffrole'] @@ -47,9 +46,9 @@ async def callback(self, interaction: discord.Interaction): existing_record = promochannel.find_one(filter) if existing_record: - promochannel.update_one(filter, {'$set': data}) + await promochannel.update_one(filter, {'$set': data}) else: - promochannel.insert_one(data) + await promochannel.insert_one(data) await refreshembed(interaction) await interaction.response.edit_message(content=None) @@ -81,22 +80,22 @@ 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': {'Promotions': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Promotions': 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': {'Promotions': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Promotions': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - promochannelresult = promochannel.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + promochannelresult = await promochannel.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" promochannelmsg = "Not Configured" if moduleddata: diff --git a/Cogs/Configuration/Views/quotaview.py b/Cogs/Configuration/Views/quotaview.py index f9a2ab59..a36069f5 100644 --- a/Cogs/Configuration/Views/quotaview.py +++ b/Cogs/Configuration/Views/quotaview.py @@ -1,14 +1,14 @@ 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) dbq = mongo['quotab'] message_quota_collection = dbq["message_quota"] -client = MongoClient(MONGO_URL) +client = AsyncIOMotorClient(MONGO_URL) db = client['astro'] modules = db['Modules'] scollection = db['staffrole'] @@ -80,7 +80,7 @@ async def callback(self, interaction: discord.Interaction): if color == 'Custom Amount': await interaction.response.send_modal(MessageQuota()) else: - message_quota_collection.update_one( + await message_quota_collection.update_one( {'guild_id': interaction.guild.id}, {'$set': {'quota': color}}, upsert=True @@ -106,7 +106,7 @@ async def on_submit(self, interaction: discord.Interaction): guild_id = interaction.guild.id - message_quota_collection.update_one( + await message_quota_collection.update_one( {'guild_id': guild_id}, {'$set': {'quota': quota_value}}, upsert=True @@ -119,8 +119,8 @@ async def on_submit(self, interaction: discord.Interaction): async def refreshembed(interaction): - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) - messagequotdata = message_quota_collection.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) + messagequotdata = await message_quota_collection.find_one({'guild_id': interaction.guild.id}) messagecountmsg = "Not Configured" if messagequotdata: messagecountmsg = f"{messagequotdata['quota']}" diff --git a/Cogs/Configuration/Views/reportview.py b/Cogs/Configuration/Views/reportview.py index 7e332c25..8a73e75d 100644 --- a/Cogs/Configuration/Views/reportview.py +++ b/Cogs/Configuration/Views/reportview.py @@ -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) +from motor.motor_asyncio import AsyncIOMotorClient +mongo = AsyncIOMotorClient(MONGO_URL) db = mongo['astro'] modules = db['Modules'] scollection = db['staffrole'] @@ -78,12 +78,12 @@ async def callback(self, interaction: discord.Interaction): 'staffrole': selected_role_id.id } try: - existing_record = ReportModeratorRole.find_one(filter) + existing_record = await ReportModeratorRole.find_one(filter) if existing_record: - ReportModeratorRole.update_one(filter, {'$set': data}) + await ReportModeratorRole.update_one(filter, {'$set': data}) else: - ReportModeratorRole.insert_one(data) + await ReportModeratorRole.insert_one(data) await refreshembed(interaction) await interaction.response.edit_message( content=None) except Exception as e: @@ -114,17 +114,17 @@ 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': {'Reports': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Reports': 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': {'Reports': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Reports': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - partnershipchannelresult = repchannel.find_one({'guild_id': interaction.guild.id}) - reportsmoderatorresult = ReportModeratorRole.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + partnershipchannelresult = await repchannel.find_one({'guild_id': interaction.guild.id}) + reportsmoderatorresult = await ReportModeratorRole.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" partnershipchannelmsg = "Not Configured" reprolemsg = "Not Configured" diff --git a/Cogs/Configuration/Views/staffpanel.py b/Cogs/Configuration/Views/staffpanel.py index d7143a6c..331aafb4 100644 --- a/Cogs/Configuration/Views/staffpanel.py +++ b/Cogs/Configuration/Views/staffpanel.py @@ -1,10 +1,10 @@ import discord import os -from pymongo import MongoClient from emojis import * +from motor.motor_asyncio import AsyncIOMotorClient MONGO_URL = os.getenv('MONGO_URL') -mongo = MongoClient(MONGO_URL) +mongo = AsyncIOMotorClient(MONGO_URL) db = mongo['astro'] modules = db['Modules'] Customisation = db['Customisation'] @@ -35,7 +35,7 @@ async def callback(self, interaction: discord.Interaction): if color == 'Reset To Default': await interaction.response.send_message(content=f"{tick} Reset To Default", ephemeral=True) - Customisation.delete_one({"name": "Staff Panel", "guild_id": interaction.guild.id}) + await Customisation.delete_one({"name": "Staff Panel", "guild_id": interaction.guild.id}) elif color == 'Customize': view = NoEmbeds( interaction.user) @@ -72,11 +72,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': {'Staff Database': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Staff Database': 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': {'Staff Database': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Staff Database': False}}, upsert=True) await refreshembed(interaction) @@ -98,7 +98,7 @@ def __init__(self): async def on_submit(self, interaction: discord.Interaction): - StaffPanelLabel.update_one({'guild_id': interaction.guild.id}, {'$set': {'label': self.Titles.value}}, upsert=True) + await StaffPanelLabel.update_one({'guild_id': interaction.guild.id}, {'$set': {'label': self.Titles.value}}, upsert=True) await interaction.response.send_message(f"{tick} **{interaction.user.display_name}**, set the dropdown label to {self.Titles.value}", ephemeral=True) @@ -476,7 +476,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt - Customisation.update_one({"name": "Staff Panel", "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True) + await Customisation.update_one({"name": "Staff Panel", "guild_id": interaction.guild.id}, {"$set": embed_data}, upsert=True) embed = discord.Embed() embed.title = f"{greencheck} Succesfully Updated" embed.description = f"Start by using /staff panel" @@ -485,7 +485,7 @@ async def Finish(self, interaction: discord.Interaction, button: discord.ui.Butt async def refreshembed(interaction): - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) if moduleddata: modulemsg = moduleddata.get('Staff Database', 'False') embed = discord.Embed(title="<:staffdb:1206253848298127370> Staff Database & Panel", description=f"**Enabled:** {modulemsg}\n\n<:Tip:1167083259444875264> If you need help either go to the [support server](https://discord.gg/36xwMFWKeC) or read the [documentation](https://docs.astrobirb.dev)", color=discord.Color.dark_embed()) diff --git a/Cogs/Configuration/Views/suggestionview.py b/Cogs/Configuration/Views/suggestionview.py index 3c6d09fa..8c00ac36 100644 --- a/Cogs/Configuration/Views/suggestionview.py +++ b/Cogs/Configuration/Views/suggestionview.py @@ -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'] @@ -45,12 +45,12 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = suggestschannel.find_one(filter) + existing_record = await suggestschannel.find_one(filter) if existing_record: - suggestschannel.update_one(filter, {'$set': data}) + await suggestschannel.update_one(filter, {'$set': data}) else: - suggestschannel.insert_one(data) + await suggestschannel.insert_one(data) await refreshembed(interaction) await interaction.response.edit_message(content=None) except Exception as e: @@ -80,12 +80,12 @@ async def callback(self, interaction: discord.Interaction): } try: - existing_record = suggestschannel2.find_one(filter) + existing_record = await suggestschannel2.find_one(filter) if existing_record: - suggestschannel2.update_one(filter, {'$set': data}) + await suggestschannel2.update_one(filter, {'$set': data}) else: - suggestschannel2.insert_one(data) + await suggestschannel2.insert_one(data) await refreshembed(interaction) await interaction.response.edit_message(content=None) except Exception as e: @@ -116,20 +116,20 @@ 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': {'Suggestions': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Suggestions': 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': {'Suggestions': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Suggestions': False}}, upsert=True) await refreshembed(interaction) async def refreshembed(interaction): - suschannelresult = suggestschannel.find_one({'guild_id': interaction.guild.id}) - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) + suschannelresult = await suggestschannel.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) modulemsg = "" suggestionchannelmsg = "Not Configured" - smschannelresult = suggestschannel2.find_one({'guild_id': interaction.guild.id}) + smschannelresult = await suggestschannel2.find_one({'guild_id': interaction.guild.id}) smschannelmsg = "Not Configured" if moduleddata: diff --git a/Cogs/Configuration/Views/suspensionsview.py b/Cogs/Configuration/Views/suspensionsview.py index 9415f184..4dfc56ac 100644 --- a/Cogs/Configuration/Views/suspensionsview.py +++ b/Cogs/Configuration/Views/suspensionsview.py @@ -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'] @@ -46,15 +46,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': {'Suspensions': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Suspensions': 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': {'Suspensions': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Suspensions': 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['Suspensions']}" diff --git a/Cogs/Configuration/Views/tagsview.py b/Cogs/Configuration/Views/tagsview.py index c7c8f626..7c6791dc 100644 --- a/Cogs/Configuration/Views/tagsview.py +++ b/Cogs/Configuration/Views/tagsview.py @@ -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'] @@ -47,11 +47,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': {'Tags': True}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Tags': 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': {'Tags': False}}, upsert=True) + await modules.update_one({'guild_id': interaction.guild.id}, {'$set': {'Tags': False}}, upsert=True) await refreshembed(interaction) class TagsUsageChannel(discord.ui.ChannelSelect): @@ -78,7 +78,7 @@ async def callback(self, interaction: discord.Interaction): try: - tagslogging.update_one(filter, {'$set': data}, upsert=True) + await tagslogging.update_one(filter, {'$set': data}, upsert=True) await refreshembed(interaction) await interaction.response.edit_message(content=None) @@ -88,8 +88,8 @@ async def callback(self, interaction: discord.Interaction): print(f"Channel ID: {channelid.id}") async def refreshembed(interaction): - moduleddata = modules.find_one({'guild_id': interaction.guild.id}) - usagechanneldata = tagslogging.find_one({'guild_id': interaction.guild.id}) + moduleddata = await modules.find_one({'guild_id': interaction.guild.id}) + usagechanneldata = await tagslogging.find_one({'guild_id': interaction.guild.id}) usagechannelmsg = "Not Configured" if usagechanneldata: usagechannelmsg = f"<#{usagechanneldata['channel_id']}>" diff --git a/Cogs/Modules/staff.py b/Cogs/Modules/staff.py index 77428624..5becfe98 100644 --- a/Cogs/Modules/staff.py +++ b/Cogs/Modules/staff.py @@ -499,8 +499,8 @@ def __init__(self): class StaffPanel(discord.ui.Select): def __init__(self): - from pymongo import MongoClient - mongo = MongoClient(MONGO_URL) + from motor.motor_asyncio import AsyncIOMotorClient + mongo = AsyncIOMotorClient(MONGO_URL) db = mongo['astro'] self.collection = db['staff database']