Skip to content

Commit 879eb43

Browse files
committed
💭Auto threads in FB ideas
1 parent 042e801 commit 879eb43

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

cogs/mod/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from cogs.mod.clear import ClearCommand
22
from cogs.mod.punishments import PunishmentCommands
3-
from cogs.mod.media_mod import MediaModeration
3+
from cogs.mod.auto_threads import AutoThreads

cogs/mod/auto_threads.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import discord
2+
from discord.ext import commands
3+
from discord import app_commands
4+
from settings import MEDIA_CHANNEL_ID, FB_IDEAS_CHANNEL_ID
5+
6+
class AutoThreads(commands.Cog):
7+
def __init__(self, bot):
8+
self.bot = bot
9+
10+
@commands.Cog.listener("on_message")
11+
async def auto_threads(self, msg):
12+
if msg.channel.id != MEDIA_CHANNEL_ID and msg.channel.id != FB_IDEAS_CHANNEL_ID:
13+
return
14+
if msg.author.bot:
15+
return
16+
if msg.channel.id == FB_IDEAS_CHANNEL_ID and "https://discord.com/channels/1138536747932864532" in msg.content:
17+
print("hi")
18+
await create_auto_thread(msg)
19+
elif msg.channel.id == MEDIA_CHANNEL_ID and (msg.attachments != [] or "https://" in msg.content or "http://" in msg.content):
20+
print(msg.channel.id == MEDIA_CHANNEL_ID)
21+
await create_auto_thread(msg)
22+
else:
23+
await msg.delete()
24+
await msg.channel.send(f"{msg.author.mention} Обсуждайте в ветках!", delete_after=3)
25+
26+
async def create_auto_thread(msg):
27+
thread_name = msg.content[:97] if msg.content != "" else f"Обсуждение медиа {msg.author.display_name}"
28+
if len(msg.content) >= 100:
29+
thread_name += "..."
30+
await msg.create_thread(name=thread_name)

cogs/mod/media_mod.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from cogs.help import HelpCommand, LinkCommand, Pin, PingHelpers, Ping_related_helpers, ResolveCommand, R_u_sure, StarterMessage, SyntaxCommand
1212
from cogs.ideas import IdeaVoteReactions
1313
from cogs.logs import Logs
14-
from cogs.mod import ClearCommand, PunishmentCommands, MediaModeration
14+
from cogs.mod import ClearCommand, PunishmentCommands, AutoThreads
1515
from cogs.minecraft import ColorCommand, FileCommand, MessageFormatter, PackformatCommand, SnapshotScraper, TemplateCommand
1616
from cogs.voice_channels import CustomVoiceChannels
1717
from utils.packmcmeta import update_mcmeta_info
@@ -25,7 +25,7 @@
2525
JoinAndLeaveMessage, SayCommand, ServerInfoCommand, BotPing,
2626
GiveawayCommand, GAModerationCommands,
2727
Logs, IdeaVoteReactions,
28-
ClearCommand, PunishmentCommands, MediaModeration,
28+
ClearCommand, PunishmentCommands, AutoThreads,
2929
SnapshotScraper, ColorCommand, FileCommand, MessageFormatter, PackformatCommand, TemplateCommand,
3030
CustomVoiceChannels,]
3131
views = [LookForView, R_u_sure, BotPingView]

settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
GIVEAWAYS_REQUESTS_CHANNEL_ID = 916725389458550805
2222
IDEAS_CHANNEL_ID = 1276169141572730880
2323
MEDIA_CHANNEL_ID = 1259458225997090910
24+
FB_IDEAS_CHANNEL_ID = 1078066910933037106
2425
JOINS_CHANNEL_ID = 916731552031969370
2526
LEAVES_CHANNEL_ID = 916751412271153182
2627
LOGS_CHANNEL_ID = 916753359304790066

0 commit comments

Comments
 (0)