Skip to content

Commit 1465318

Browse files
authoredJan 26, 2025
Merge pull request #30 from sighrelief/master
🍪/📌 reactions, / commands, bug fixes
2 parents 0383169 + e4b3d9f commit 1465318

File tree

6 files changed

+59
-69
lines changed

6 files changed

+59
-69
lines changed
 

‎cogs/admin.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
32
import discord
43
from discord import MessageType, ChannelType
54
from discord.ext import commands
@@ -21,7 +20,7 @@ async def purge(self, ctx: commands.context.Context, n: int):
2120
reply = await ctx.send(f'{len(deleted) - 1} message(s) purged')
2221
await reply.delete(delay=1)
2322

24-
@commands.hybrid_command()
23+
@commands.command()
2524
@commands.has_permissions(manage_guild=True)
2625
async def status(self, ctx):
2726
"""Set the bot's playing status"""
@@ -116,38 +115,40 @@ async def rolepurge(self, ctx):
116115
await timewarning.delete()
117116
await ctx.message.delete()
118117

118+
119119
@commands.Cog.listener()
120-
async def on_message(self, message: discord.Message):
121-
"""Automatically delete non-media messages in media channels and add 📌 reaction to media messages"""
120+
async def on_message(self, message: discord.Message): # known bug: wont act as media channel if channel contains text 'original' or 'selfies'
121+
"""Automatically delete non-media messages in media channels | add 📌 and/or 🍪 reaction to media messages"""
122+
if message.channel.name.find('original') > -1 or message.channel.name.find('selfies') > -1: # looks for the position of substring. if it's not found, this returns -1.
123+
await asyncio.sleep(2.500) #wait for embeds
124+
if len(message.embeds) + len(message.attachments) > 0:
125+
await message.add_reaction('📌')
126+
await message.add_reaction('<:CookieHeart:673558008185487381>')
127+
return
128+
122129
if message.author.id == self.bot.user.id:
123130
return
124-
# We need to check if it is a member because webhook message authors are not members and can't have permissions.
131+
# We need to check if it is a member in addition since webhook message authors are not members and can't have permissions.
125132
if message.author is discord.Member and message.author.guild_permissions.administrator:
126133
return
127-
if message.type not in (MessageType.default, MessageType.reply):
128-
return
129134
if message.channel.type != ChannelType.text:
130135
return
136+
if message.type not in (MessageType.default, MessageType.reply):
137+
return
131138
if message.channel.name.find(
132139
'media') == -1: # looks for the position of substring. if it's not found, this returns -1.
133140
return
134-
# We need to wait a bit in-case discord generates embeds or adds attachments.
135-
await asyncio.sleep(2.500)
141+
142+
await asyncio.sleep(2.500) #wait for embeds
136143
if len(message.embeds) + len(message.attachments) > 0:
137144
await message.add_reaction('📌') # doesn't check if channel is private, only if media isn't in the name
138145
return
139146
try:
147+
await message.channel.send(f'<@{message.author.id}> Sorry, you can\'t talk in media channels, but you can start a thread! if you posted media, try again and make sure it embedded properly',
148+
delete_after=8)
140149
await message.delete()
141-
await message.channel.send('Unfortunately, you can\'t talk in media channels. You have to send either \
142-
an attachment or embed with your message. If you sent a link, discord timed out and didn\'t embed the message. \
143-
(discord can struggle to do this when the file size is large, especially when their servers are being slow). \
144-
You can try again, or you can download whatever is at the link and upload it to discord manually. Don\'t be afraid to \
145-
try multiple times. This is all a discord limitation we can\'t do anything about at the moment. Sorry :(',
146-
delete_after=12)
147-
except discord.NotFound:
148-
# Message was already deleted.
150+
except discord.NotFound: # Message was already deleted.
149151
pass
150152

151-
152153
async def setup(bot):
153154
await bot.add_cog(Admin(bot))

‎cogs/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def roll(self, ctx, sides="6", num="1"):
4040
if not num.isdigit():
4141
num = "1"
4242
if not sides.isdigit():
43-
await ctx.send(f'<@{ctx.author.id}> I\'m not sure i get it... <:MeruSad:633650580660682762> \
43+
await ctx.send(f'<@{ctx.author.id}> I\'m not sure i get it... <:MeruSad:935943233626861568> \
4444
Could you try it like this? <:QuestionBun:588539387688517642> \n\
4545
`.roll d[number of sides] [number of dice]`')
4646
elif int(sides) == 0 or int(num) == 0:

‎cogs/misc.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def __init__(self, bot: commands.Bot):
1010
@commands.command()
1111
async def faq(self, ctx):
1212
"""FAQ/Copypasta list"""
13-
await ctx.message.delete()
1413
await ctx.send('''
1514
## Gay Baby Jail - Frequently Asked Questions
1615
Below is a list of commands you can use to either learn more about the server or quickly educate others
@@ -19,10 +18,9 @@ async def faq(self, ctx):
1918
* Other: `.feedback`, `.roleplay`, `.textrules`, `.lights`, `.discussion`, `.mediaguide`
2019
''')
2120

22-
@commands.command()
21+
@commands.hybrid_command()
2322
async def economy(self, ctx):
2423
"""copypasta command explaining all the ways to earn cookies in the economy"""
25-
await ctx.message.delete()
2624
await ctx.send('''
2725
# Learn how to succeed in the GBJ economy
2826
## Earning Cookies
@@ -43,10 +41,9 @@ async def economy(self, ctx):
4341
- To see all the roles you can purchase, type `.allroles`.
4442
''')
4543

46-
@commands.command(aliases=["diaperserver"])
44+
@commands.hybrid_command(aliases=["diaperserver"])
4745
async def discussion(self, ctx):
4846
"""copypasta command explaining why we allow and encourage serious or adult conversations"""
49-
await ctx.message.delete()
5047
await ctx.send(
5148
'''Gay Baby Jail is not _just_ a diaper server. Its mostly a hangout server where diapers are normalized. \
5249
We don't allow roleplay or baby-talk in the generals, and we're all adults. While serious topics aren't always being \
@@ -57,10 +54,9 @@ async def discussion(self, ctx):
5754
visit in the meantime as well. Thank you for your understanding.
5855
''')
5956

60-
@commands.command()
57+
@commands.hybrid_command()
6158
async def modmail(self, ctx):
6259
"""copypasta command explaining modmail"""
63-
await ctx.message.delete()
6460
await ctx.send('''\
6561
# How do I contact the GBJ staff?
6662
Head to <#1172337920431104053>, and click `Open a ticket!`. This will put you in a channel with staff only, where you can express your concerns.
@@ -71,10 +67,9 @@ async def modmail(self, ctx):
7167
If you believe it's urgent, and the server is in danger, you may message any of the available babysitters individually. Abusing this may result in a warning.
7268
''')
7369

74-
@commands.command(aliases=["mediaguide", "media", "mediaguidelines"])
70+
@commands.hybrid_command(aliases=["mediaguide", "media", "mediaguidelines"])
7571
async def mediaguideline(self, ctx):
7672
"""copypasta command explaining what kind of images are allowed in media channels"""
77-
await ctx.message.delete()
7873
await ctx.send('''\
7974
Images which have the intention of being (abdl-)memes rather than "abdl-media" should be posted in \
8075
<#639395194898219011>, and should not be posted in media channels. Posts in media channels must somehow pass as art, \
@@ -83,10 +78,9 @@ async def mediaguideline(self, ctx):
8378
it when you see it".
8479
[**Here's a few examples of what and what not to post in media channels (img-link)**](https://files.catbox.moe/e3vxwj.png)''')
8580

86-
@commands.command(aliases=["pk"])
81+
@commands.hybrid_command(aliases=["pk"])
8782
async def pluralkit(self, ctx):
8883
"""copypasta command explaining what pluralkit is"""
89-
await ctx.message.delete()
9084
await ctx.send('''
9185
## ____Why Are There Bots Talking?____
9286
<@!466378653216014359> is a bot designed for plural systems that use Discord. It allows you to register systems, \
@@ -102,10 +96,9 @@ async def pluralkit(self, ctx):
10296
or by using `pk;help in <#395837746083528704>`
10397
You can learn more about plurality on [MoreThanOne.info](<https://morethanone.info/>)''')
10498

105-
@commands.command(aliases=["listroles", "roleslist", "rolelist"])
99+
@commands.hybrid_command(aliases=["listroles", "roleslist", "rolelist"])
106100
async def allroles(self, ctx):
107101
"""copypasta command that lists all available roles"""
108-
await ctx.message.delete()
109102
await ctx.send('''\
110103
## All Custom Roles
111104
We had to move the list to [this google sheet](<https://bit.ly/3Bd1Zbq>), it doesn't fit in discord anymore!
@@ -114,10 +107,9 @@ async def allroles(self, ctx):
114107
`.diapertraining` in <#395837746083528704> for more info.\
115108
''')
116109

117-
@commands.command()
110+
@commands.hybrid_command()
118111
async def diapertraining(self, ctx):
119112
"""copypasta explaining the diapertraining role"""
120-
await ctx.message.delete()
121113
await ctx.send('''\
122114
## <:PottyBanned:779149826154823691> What Is This?
123115
When the Diaper Training role is pinged, all users must prove they're wearing a diaper with a picture. \
@@ -136,20 +128,9 @@ async def diapertraining(self, ctx):
136128
**If you're caught lying or reusing an old photo, you will be banned from the server for 14 days.**
137129
''')
138130

139-
@commands.command(aliases=["suggest", "suggestion"])
140-
async def feedback(self, ctx):
141-
"""copypasta command template"""
142-
await ctx.message.delete()
143-
await ctx.send('''\
144-
If you'd like to submit feedback or suggestions to the server, it's bots, etc., you can use \
145-
`?suggest [your suggestion]`. This will create a poll which is sent to <#466459060258996225>, which helps us to gauge \
146-
interest and support.
147-
''')
148-
149-
@commands.command(aliases=["rule2", "rp"])
131+
@commands.hybrid_command(aliases=["rule2", "rp"])
150132
async def roleplay(self, ctx):
151-
"""copypasta command template"""
152-
await ctx.message.delete()
133+
"""copypasta explaining our roleplay rule"""
153134
await ctx.send('''\
154135
## Rule 2: No Roleplay (or baby-talk)
155136
We understand this is a very divisive rule which many don't understand. In short, we haven't curated GBJ to be a \
@@ -177,20 +158,18 @@ async def roleplay(self, ctx):
177158
completely free. Albeit they only work in servers I'm a part of.
178159
''')
179160

180-
@commands.command(aliases=["rules"])
161+
@commands.hybrid_command(aliases=["rules"])
181162
async def textrules(self, ctx):
182-
"""copypasta command template"""
183-
await ctx.message.delete()
163+
"""copypasta linking our rules on gdocs"""
184164
await ctx.send('''\
185165
[Here's a link to our current rules in plain text]\
186166
(https://docs.google.com/document/d/13pxzthxFImkSLBOit4u4J6QXi2_5cbVq41qcwcnBYFE). \
187167
You can make a copy by clicking `File > Make a copy` if you need to make it more readable.
188168
''')
189169

190-
@commands.command()
170+
@commands.hybrid_command()
191171
async def lights(self, ctx):
192-
"""copypasta command template"""
193-
await ctx.message.delete()
172+
"""copypasta for lights"""
194173
await ctx.send('''\
195174
## Consent Indicators (aka lights)
196175
* <:LightGreen:749514803822854224>: All clear, everything is going well. I consent.

‎cogs/pinboard.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import logging
2-
3-
import discord
4-
from discord import MessageType, Embed, Webhook
5-
from discord.ext import commands
62
import aiohttp
73
import asyncio
4+
import time
5+
import discord
6+
from discord import MessageType, ChannelType, Embed, Webhook
7+
from discord.ext import commands
8+
89

910
log = logging.getLogger("cogs.pinboard")
1011

@@ -19,11 +20,15 @@ async def on_raw_reaction_add(self, payload,):
1920
f"""auto-pin messages after {n} human 📌 reactions"""
2021
channel = self.bot.get_channel(payload.channel_id)
2122
message = await channel.fetch_message(payload.message_id)
23+
if message.type == MessageType.pins_add: #ignore [user] pinned a message server messages
24+
return
2225
for reaction in message.reactions:
2326
if reaction.emoji == '📌':
2427
# reaction.me checks if bot reacted, if False that means the message has already been pinned and should return.
2528
if reaction.count == n+1 and reaction.me:
2629
await reaction.remove(self.bot.user)
30+
if time.time() - message.created_at.timestamp() > 7889399: # 7889399 being 3 months in seconds
31+
return
2732
await message.pin()
2833
log.info(f'bot pinned a message because of {reaction.count} 📌 reactions on message')
2934
if reaction.count == 1 and reaction.me is False:
@@ -34,6 +39,10 @@ async def on_raw_reaction_add(self, payload,):
3439
@commands.Cog.listener()
3540
async def on_message(self, message: discord.Message):
3641
"""When a message is pinned, push an embed of that message through a webhook"""
42+
43+
if message.channel.name.find('pinboard') > -1 and message.author != discord.Member: #publish the message if its a webhook message in #pinboard
44+
await message.publish()
45+
3746
if message.type != MessageType.pins_add:
3847
return
3948
everyone = None

‎cogs/stamps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
IMAGE_AND_JSON_SUFFIXES = set(IMAGE_SUFFIXES)
1111
IMAGE_AND_JSON_SUFFIXES.add('.json')
1212

13-
1413
def snake_to_camel(name):
1514
"""Converts snake_case to CamelCase"""
1615
return "".join(word.capitalize() for word in name.split("_"))
@@ -200,11 +199,11 @@ async def cmd(cog: commands.Cog, ctx: commands.Context, *args, **kwargs):
200199

201200
return cmd
202201

203-
@commands.command()
202+
@commands.hybrid_command()
204203
async def stamps(self, ctx):
205204
"""Prints out a list of stamp categories"""
206205
categories = " ".join(self.category_names)
207-
await ctx.send(f'Here\'s a list of our stamp packs!\nType `{self.bot.command_prefix}[pack-name]` to see a list of the stamps inside of that pack.```{categories}``` Also, you can add stamps in the `!shop`!'.strip())
206+
await ctx.send(f'Here\'s a list of our stamp packs!\nType `{self.bot.command_prefix}[pack-name]` to see a list of the stamps inside of that pack.```{categories}``` Also, you can add stamps in the `!shop`!\nPlease note that these cannot be invoked as a / command'.strip())
208207

209208

210209
async def setup(bot):

‎requirements.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
aiohttp==3.10.5
2-
aiosignal==1.3.1
3-
async-timeout==4.0.3
4-
attrs==24.2.0
5-
charset-normalizer==3.3.2
1+
aiohttp==3.11.11
2+
aiosignal==1.3.2
3+
async-timeout==5.0.1
4+
attrs==24.3.0
5+
charset-normalizer==3.4.1
66
discord.py==2.4.0
7-
frozenlist==1.4.1
8-
# idna==3.8
9-
multidict==6.0.5
10-
yarl==1.9.7
7+
frozenlist==1.5.0
8+
# idna==3.4
9+
multidict==6.1.0
10+
yarl==1.18.3
11+
# audioop is needed to run cookie in python 3.13 unstable. Will not be needed when 3.13 becomes stable and discord.py supports it.
12+
audioop-lts==0.2.1

0 commit comments

Comments
 (0)
Please sign in to comment.