анонки

"cogs": ["cogs.confess.confess"] - ну ты понял что это
!setconfess #нужный-канал - указать канал для анонок
!confess текст анонки - юзер пишет любую хуйню
This commit is contained in:
2026-05-27 17:10:25 +00:00
parent 52da79db7e
commit 097a0383b8
2 changed files with 68 additions and 0 deletions

60
cogs/confess/confess.py Normal file
View File

@@ -0,0 +1,60 @@
import discord
from discord.ext import commands
import json
import os
CONFIG_PATH = os.path.join(os.path.dirname(__file__), "config.json")
def load_config():
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)
def save_config(data):
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
class ConfessCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.config = load_config()
@commands.command(name="confess")
async def confess(self, ctx, *, text: str):
if not isinstance(ctx.channel, discord.DMChannel):
await ctx.send("Пиши мне в личку, а не сюда.")
return
channel_id = self.config.get("confess_channel_id", 0)
if not channel_id:
await ctx.send("Канал для анонок не настроен, скажи админу прописать `!setconfess #канал`.")
return
channel = self.bot.get_channel(channel_id)
if channel is None:
await ctx.send("Не могу найти канал, скажи админу проверить настройки.")
return
embed = discord.Embed(description=text, color=self.config.get("embed_color", 7419530))
embed.set_footer(text=self.config.get("footer", "Анонка"))
await channel.send(embed=embed)
await ctx.send("Анонка отправлена, никто не знает что это ты.")
@commands.command(name="setconfess")
@commands.has_permissions(administrator=True)
async def setconfess(self, ctx, channel: discord.TextChannel):
self.config["confess_channel_id"] = channel.id
save_config(self.config)
await ctx.send(f"Анонки теперь идут в {channel.mention}.")
@confess.error
async def confess_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("А текст? Пиши так: `!confess твой текст`")
async def setup(bot):
await bot.add_cog(ConfessCog(bot))

8
cogs/confess/config.json Normal file
View File

@@ -0,0 +1,8 @@
{
"description": "Анонимные конфессии через ЛС бота",
"usages": ["confess <текст>"],
"hidden": false,
"confess_channel_id": 0,
"embed_color": 7419530,
"footer": "Анонка"
}