Skip to content

Commit

Permalink
fix emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsbirb committed May 1, 2024
1 parent 3f67162 commit e6ffee4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
18 changes: 15 additions & 3 deletions Cogs/Configuration/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from Cogs.Configuration.Views.tagsview import TagsUsageChannel

from Cogs.Configuration.Views.quotaview import QuotaToggle
from Cogs.Configuration.Views.quotaview import QuotaAmount
from Cogs.Configuration.Views.quotaview import QuotaAmount, IgnoredChannel


from Cogs.Configuration.Views.feedbackview import FeedbackChannel, FMoreOptions
from Cogs.Configuration.Views.feedbackview import ToggleFeedback
Expand Down Expand Up @@ -108,6 +109,8 @@
qotds = db['qotd']
premium = db['premium']
prefixdb = db['prefixes']
ignoredchannels = db2['Ignored Quota Channels']

class StaffRole(discord.ui.RoleSelect):
def __init__(self, author, roles):

Expand Down Expand Up @@ -539,20 +542,28 @@ async def callback(self, interaction: discord.Interaction):
elif color == 'Message Quota': # Tags
moduleddata = modules.find_one({'guild_id': interaction.guild.id})
messagequotdata = message_quota_collection.find_one({'guild_id': interaction.guild.id})
ignoredchannelsresult = ignoredchannels.find_one({'guild_id': interaction.guild.id})
messagecountmsg = "Not Configured"
if messagequotdata:
messagecountmsg = f"{messagequotdata['quota']}"
modulemsg = "True"
if moduleddata:
modulemsg = f"{moduleddata['Quota']}"
channels = []
if ignoredchannelsresult and ignoredchannelsresult.get('channels'):
for channel_id in ignoredchannelsresult.get('channels', []):
channel = interaction.guild.get_channel(channel_id)
if channel:
channels.append(channel)

embed = discord.Embed(title="<:quota:1234994790056198175> Message Quota Module", color=discord.Color.dark_embed())
embed.add_field(name="<:settings:1207368347931516928> Message Quota Configuration", value=f"{replytop}**Enabled:** {modulemsg}\n{replybottom}**Quota:** {messagecountmsg}\n\n<:Tip:1223062864793702431> 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)
options = [
discord.SelectOption(label="Enabled"),
discord.SelectOption(label="Disabled")]
view = QuotaModule(self.author, options)
view = QuotaModule(self.author, options, channels)

elif color == 'Staff Feedback': #StaffFeed
feedbackchannelresult = feedbackch.find_one({'guild_id': interaction.guild.id})
Expand Down Expand Up @@ -1203,10 +1214,11 @@ def __init__(self, author, options):


class QuotaModule(discord.ui.View):
def __init__(self, author, options):
def __init__(self, author, options, channels):
super().__init__(timeout=None)
self.add_item(QuotaToggle(author, options))
self.add_item(QuotaAmount(author))
self.add_item(IgnoredChannel(author, channels))
self.add_item(Config(author))


Expand Down
33 changes: 33 additions & 0 deletions Cogs/Configuration/Views/quotaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
dbq = mongo['quotab']
message_quota_collection = dbq["message_quota"]

ignoredchannels = dbq['Ignored Quota Channels']

client = AsyncIOMotorClient(MONGO_URL)
db = client['astro']
modules = db['Modules']
Expand All @@ -26,6 +28,10 @@
partnershipsch = db['Partnerships Channel']
modules = db['Modules']





class QuotaToggle(discord.ui.Select):
def __init__(self, author, options):
self.author = author
Expand All @@ -51,6 +57,33 @@ async def callback(self, interaction: discord.Interaction):
await refreshembed(interaction)


class IgnoredChannel(discord.ui.ChannelSelect):
def __init__(self, author, channels):
super().__init__(placeholder='Ignored Channels', channel_types=[discord.ChannelType.text, discord.ChannelType.news], default_values=channels, max_values=25)
self.author = author

async def callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author.id:
embed = discord.Embed(description=f"{redx} **{interaction.user.global_name},** this is not your panel!",
color=discord.Colour.brand_red())
return await interaction.response.send_message(embed=embed, ephemeral=True)
await interaction.response.defer(ephemeral=True)

channelids = [channel.id for channel in self.values]

filter = {
'guild_id': interaction.guild.id
}

try:
await ignoredchannels.update_one(filter, {'$set': {'channel_ids': channelids}}, upsert=True)
await refreshembed(interaction)
await interaction.edit_original_response(content=None)
except Exception as e:
print(f"An error occurred: {str(e)}")

print(f"Channel IDs: {channelids}")

class QuotaAmount(discord.ui.Select):
def __init__(self, author):
self.author = author
Expand Down
15 changes: 11 additions & 4 deletions Cogs/Events/messagevent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from discord.ext import commands

import discord
from motor.motor_asyncio import AsyncIOMotorClient
import os
from dotenv import load_dotenv
Expand All @@ -14,9 +14,9 @@


db2 = mongo['quotab']

ignoredchannels = db2['Ignored Quota Channels']
mccollection = db2["messages"]

ignoredchannels = db2['Ignored Quota Channels']
MONGO_URL = os.getenv('MONGO_URL')
astro = AsyncIOMotorClient(MONGO_URL)
db = astro['astro']
Expand All @@ -29,10 +29,11 @@ def __init__(self, client):
self.client = client

@commands.Cog.listener()
async def on_message(self, message):
async def on_message(self, message: discord.Message):
if message.guild is None:
return
module = await modules.find_one({'guild_id': message.guild.id})

if module:
if module.get('Quota', False) is False:
return
Expand All @@ -47,6 +48,11 @@ async def on_message(self, message):

staff_data = await scollection2.find_one({'guild_id': message.guild.id})
admin_data = await arole.find_one({'guild_id': message.guild.id})
ignoredchannelsresult = await ignoredchannels.find_one({'guild_id': message.guild.id})
if ignoredchannelsresult:
if message.channel.id in ignoredchannelsresult.get('channel_ids', []):
return

if staff_data is None or 'staffrole' not in staff_data:
return
if admin_data is None or 'staffrole' not in admin_data:
Expand All @@ -56,6 +62,7 @@ async def on_message(self, message):
admin_role_ids = admin_data['staffrole']
if not isinstance(staff_role_ids, list):
staff_role_ids = [staff_role_ids]


if any(role.id in staff_role_ids for role in message.author.roles):

Expand Down
2 changes: 1 addition & 1 deletion emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tagsemoji = "<:tag:1234998802948034721>"
infractions = "<:Infraction:1223063128275943544> "
promotions = "<:Promotion:1234997026677198938>"
dropdown = "<:ArrowDropDown:1223063384946249789> "
dropdown = "<:ArrowDropDown:1163171628050563153>"

greencheck = "<:check312:1214614441812041838>"
redx = "<:cxk123:1214614818951266314>"
Expand Down

0 comments on commit e6ffee4

Please sign in to comment.