This commit is contained in:
2025-11-26 19:34:08 +05:00
commit 1dd4394e4b
11 changed files with 926 additions and 0 deletions

63
c/error.py Normal file
View File

@@ -0,0 +1,63 @@
import discord
import traceback
import sys
from discord.ext import commands
class Error(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if hasattr(ctx.command, "on_error"):
return
cog = ctx.cog
if cog:
if cog._get_overridden_method(cog.cog_command_error) is not None:
return
ignored = (commands.CommandNotFound,)
error = getattr(error, "original", error)
if isinstance(error, ignored):
return
if isinstance(error, commands.DisabledCommand):
await ctx.send(f"{ctx.command} has been disabled.")
elif isinstance(error, commands.NoPrivateMessage):
try:
await ctx.author.send(
f"{ctx.command} can not be used in Private Messages."
)
except discord.HTTPException:
pass
elif isinstance(error, commands.BadArgument):
if ctx.command.qualified_name == "tag list":
await ctx.send("I could not find that member. Please try again.")
elif isinstance(error, commands.MissingPermissions):
await ctx.reply("Ээм друк у тебя нет прав на использование этой команды!!")
elif isinstance(error, commands.NotOwner):
await ctx.reply("Эта команда доступна только владельцу бота!!!")
else:
print(
"Ignoring exception in command {}:".format(ctx.command), file=sys.stderr
)
# traceback.print_exception(
# type(error), error, error.__traceback__, file=sys.stderr
# )
print(error)
@commands.Cog.listener()
async def on_ready(self):
print('Error cog has been loaded')
async def setup(bot):
await bot.add_cog(Error(bot))

165
c/filter.py Normal file
View File

@@ -0,0 +1,165 @@
import string
import discord
from discord.ext import commands
from discord.ext.commands import Context, has_permissions
import random
import config
bad = ['бля', 'хуй', 'пиздец', 'сука', 'ебать', 'ебанат', 'хуя', 'уебан', 'пидор', 'ебаный', 'блять','уебу','пиздану','пизду', 'блядь', 'чивапчичи']
class Filter(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
async def write(self, name, server_id, channel_id):
tog = 1
self.bot.confmsg.execute("INSERT INTO channel(tog, name, server_id, channel_id) VALUES(?, ?, ?, ?)", (tog, name, server_id, channel_id,))
self.bot.confmsg.commit()
async def delete(self, name, server_id, channel_id):
self.bot.confmsg.execute("DELETE FROM channel WHERE name=? AND server_id=? AND channel_id=?",(name, server_id, channel_id))
self.bot.confmsg.commit()
async def badwords(self, message, serid, chanid):
name = 'badwords'
res = await self.bot.select(name, serid, chanid)
if res == "disabled":
pass
elif res == "enabled":
if {i.lower().translate(str.maketrans('ё', 'е', string.punctuation)) for i in message.content.split(' ')} \
.intersection(set(bad)) != set():
await message.reply("не матерись блядь")
print(f'------------------------------------\nmessage with bad word: {message.content}\n------------------------------------')
async def message(self, message, server_id, channel_id):
if message.content.startswith(config.PREFIX):
return
name = 'msgsend'
res = await self.bot.select(name, server_id, channel_id)
if res == "disabled":
pass
elif res == "enabled":
msg = message.content
server_id = message.guild.id
rows = self.bot.conmsg.execute("SELECT id FROM message WHERE server_id=? ORDER BY id DESC LIMIT 1", (server_id,))
resultsid = rows.fetchone()
print("------------------------------------\nserverid: ", server_id,"\nmessage content: ", msg, "\n------------------------------------")
if resultsid == None:
message_id = 1
else:
message_id = resultsid[0] + 1
self.bot.conmsg.execute("INSERT INTO message(id, server_id, messages) VALUES (?, ?, ?)", (message_id, server_id, msg))
self.bot.conmsg.commit()
c = 5
a = random.randrange(0, c)
if a == 1:
b = random.randrange(1, message_id)
rows2 = self.bot.conmsg.execute("SELECT messages FROM message WHERE id=? AND server_id=? ORDER BY id DESC LIMIT 1", (b, server_id,))
msgresult = rows2.fetchall()
print('------------------------------------\nmessage send content: ', msgresult, '\n------------------------------------')
await message.channel.send(" ".join(msgresult[0]))
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return
server_id = message.guild.id
channel_id = message.channel.id
await self.badwords(message, server_id, channel_id)
await self.message(message, server_id, channel_id)
@commands.command()
@commands.is_owner()
async def clear_msgdb(self, message):
"""
Clear db for 'message'
"""
server_id = message.guild.id
rows = self.bot.conmsg.execute("SELECT id FROM message WHERE server_id=? ORDER BY id DESC LIMIT 1", (server_id,))
result = rows.fetchone()
self.bot.conmsg.execute("DELETE FROM message WHERE server_id=?", (server_id,))
self.bot.conmsg.commit()
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title="Message history has been deletet"
)
embed.add_field(name="number of msg:", value=f'{result}')
await message.send(embed=embed)
@commands.command()
@commands.is_owner()
async def msgdb(self, message):
"""
Total number of DB msgsend
"""
server_id = message.guild.id
rows = self.bot.conmsg.execute("SELECT id FROM message WHERE server_id=? ORDER BY id DESC LIMIT 1", (server_id,))
result = rows.fetchone()
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title="Total number of msg"
)
embed.add_field(name=" ", value=f'{result}')
await message.send(embed=embed)
@commands.command()
@commands.is_owner()
async def toggle(self, ctx, *msg):
"""
Toggle(msgsend, badwords, logs)
"""
server_id = ctx.guild.id
channel_id = ctx.channel.id
name = " ".join(msg)
if name != "msgsend" and name != "badwords" and name != "logs":
embed = discord.Embed(
title="select what you want to toggle",
color=random.randint(0, 0xFFFFFF),
)
else:
res = await self.bot.select(name, server_id, channel_id)
if res == "disabled":
embed = discord.Embed(
title=f"{name} has been enabled",
color=random.randint(0, 0xFFFFFF),
)
await self.write(name, server_id, channel_id)
elif res == 'enabled':
embed = discord.Embed(
title=f"{name} has been disabled",
color=random.randint(0, 0xFFFFFF),
)
await self.delete(name, server_id, channel_id)
await ctx.send(embed=embed)
@commands.command()
@commands.is_owner()
async def status(self, ctx):
"""
"""
server_id = ctx.guild.id
channel_id = ctx.channel.id
bw = await self.bot.select(name='badwords', server_id=server_id, channel_id=channel_id)
msgsend = await self.bot.select(name='msgsend', server_id=server_id, channel_id=channel_id)
logs = await self.bot.select(name='logs', server_id=server_id, channel_id=channel_id)
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title="status"
)
embed.add_field(name="badwords", value=f'{bw}')
embed.add_field(name="msgsend", value=f'{msgsend}')
embed.add_field(name="logs", value=f'{logs}')
await ctx.send(embed=embed)
@commands.Cog.listener()
async def on_ready(self):
print('Filter cog has been loaded')
async def setup(bot):
await bot.add_cog(Filter(bot))

53
c/fun.py Normal file
View File

@@ -0,0 +1,53 @@
from discord.ext import commands
import random
import re
class Fun(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
@commands.command()
async def roll(self, message, *args):
"""
roll xdy+...
"""
# split
content = content=" ".join(args)
numb = re.split(r'[d+\s]+', content)
print("content: ", content)
rand = 0
i = 0
array = []
sumrand = 0
try:
# multiple dice and range
while i < int(numb[0]):
rand = random.randint(1, int(numb[1]))
array.append(rand)
print("dice: ", array[i])
i += 1
# sum dice
for j in array:
sumrand += int(j)
vse = 0
# count range array
for g in numb:
vse += 1
vse -= 1
i = 2
# sum dice + all after xdx+
while i <= vse:
sumrand += int(numb[i])
i += 1
await message.channel.send(f"{message.author.display_name} Request: {content} Roll: {array} Result: {sumrand}")
except:
await message.channel.send("try xdx+x..")
@commands.Cog.listener()
async def on_ready(self):
print('Fun cog has been loaded')
async def setup(bot):
await bot.add_cog(Fun(bot))

111
c/info.py Normal file
View File

@@ -0,0 +1,111 @@
import discord
from discord.ext import commands
from discord.ext.commands import Context
import random
class Info(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
@commands.command()
async def avatar(self, ctx, member: discord.Member = None):
"""
Gets user avatar
"""
if member is None:
member = ctx.author
if member.avatar:
embed = discord.Embed(
title=f'Avatar {member}',
color=random.randint(0, 0xFFFFFF),
).set_image(url = member.avatar.url)
else:
embed = discord.Embed(
title=f"{member} has no avatar",
color=random.randint(0, 0xFFFFFF),
)
await ctx.send(embed=embed)
@commands.command()
async def serverinfo(self, context: Context) -> None:
"""
Get some useful (or not) information about the server
:param context: The hybrid command context.
"""
roles = [role.name for role in context.guild.roles]
num_roles = len(roles)
if num_roles > 50:
roles = roles[:50]
roles.append(f">>>> Displaying [50/{num_roles}] Roles")
roles = ", ".join(roles)
embed = discord.Embed(
title="**Server Name:**", description=f"{context.guild}", color=random.randint(0, 0xFFFFFF)
)
if context.guild.icon is not None:
embed.set_thumbnail(url=context.guild.icon.url)
embed.add_field(name="Server ID", value=context.guild.id)
embed.add_field(name="Member Count", value=context.guild.member_count)
embed.add_field(
name="Text/Voice Channels", value=f"{len(context.guild.channels)}"
)
embed.add_field(name=f"Roles ({len(context.guild.roles)})", value=roles)
embed.set_footer(text=f"Created at: {context.guild.created_at}")
await context.send(embed=embed)
@commands.command()
async def userinfo(self, ctx, member: discord.Member = None) -> None:
"""
Gets some information about user
"""
if member is None:
member = ctx.author
roles = [role.name for role in member.roles]
roles = ", ".join(roles)
embed = discord.Embed(
title="**Displayed name:**",
description=member.display_name,
color=random.randint(0, 0xFFFFFF)
)
if member.avatar:
embed.set_thumbnail(url=member.avatar.url)
embed.add_field(name="Username", value=member)
embed.add_field(name="User ID", value=member.id)
embed.add_field(name=" ", value=' ')
embed.add_field(name="User status", value=member.status)
embed.add_field(name="_ _", value=member.activity)
embed.add_field(name=" ", value=' ')
embed.add_field(name=f"User roles ({len(member.roles)})", value= roles )
embed.add_field(name="User join on server at", value=member.joined_at)
embed.set_footer(text=f"Account created at: {member.created_at}")
await ctx.send(embed=embed)
@commands.command()
async def serveravatar(self, context: Context) -> None:
"""
Get server avatar
"""
embed = discord.Embed(
title='Avatar',
color=random.randint(0, 0xFFFFFF),
).set_image(url = context.guild.icon.url).set_author(name= context.guild.name, icon_url = context.guild.icon.url)
await context.send(embed=embed)
@commands.Cog.listener()
async def on_ready(self):
print('Info cog has been loaded')
async def setup(bot):
await bot.add_cog(Info(bot))

64
c/log.py Normal file
View File

@@ -0,0 +1,64 @@
import discord
from discord.ext import commands
from discord.ext.commands import Context
import random
class Logger(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
@commands.Cog.listener()
async def on_message_delete(self, context = Context):
if context.author.bot:
return
try:
res = await self.bot.ch(server_id=context.guild.id)
print("------------------------------------\ndeleted message: ", f'{context.content}\n------------------------------------')
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title='Message deleted'
)
embed.add_field(name=f'', value=f'[link]({context.jump_url})', inline=False)
embed.set_author(name=context.author.name, icon_url = context.author.avatar.url)
embed.add_field(name='content:', value=f'{context.content}')
if context.attachments:
a = 0
for attachment in context.attachments:
a = a + 1
embed.add_field(name=f"attachment #{a}", value=attachment, inline = False)
embed.add_field(name='', value=f'#{context.channel}', inline = False)
channel = self.bot.get_channel(int(res))
await channel.send(embed=embed)
except:
pass
@commands.Cog.listener()
async def on_message_edit(self, message_before, message_after):
if message_before.author.bot:
return
try:
res = await self.bot.ch(server_id=message_before.guild.id)
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title='Message edited'
)
embed.add_field(name=f'', value=f'[link]({message_before.jump_url})', inline=False)
embed.set_author(name=message_before.author.name, icon_url = message_before.author.avatar.url)
embed.add_field(name='before:', value=f'{message_before.content}')
embed.add_field(name='after:', value=f'{message_after.content}')
embed.add_field(name='', value=f'#{message_before.channel}', inline = False)
channel = self.bot.get_channel(int(res))
await channel.send(embed=embed)
except:
pass
@commands.Cog.listener()
async def on_ready(self):
print('Logger cog has been loaded')
async def setup(bot):
await bot.add_cog(Logger(bot))

331
c/moderation.py Normal file
View File

@@ -0,0 +1,331 @@
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, Context
import random
import datetime
class Moderation(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
@commands.command()
@has_permissions(kick_members=True)
async def kick(self, ctx, user: discord.Member = None, *, reason: str = "Not specified"):
"""
Kick a user from server
"""
embed = discord.Embed(
title=f"{user} was kicked by {ctx.author}",
color=random.randint(0, 0xFFFFFF),
)
embed.add_field(name="Reason:", value=reason)
try:
await user.kick(reason= reason)
except:
embed = discord.Embed(
title="An error occurred while trying to kick the user. Make sure ID is an existing ID that belongs to a user.",
color=0xE02B2B,
)
await ctx.send(embed=embed)
await user.send(f'you were kicked by {ctx.author} from {ctx.guild.name} for {reason}')
@commands.command()
@has_permissions(kick_members=True)
async def ban(self, ctx, user: discord.Member = None, *, reason: str = "Not specified"):
"""
Ban a user from server
"""
embed = discord.Embed(
title=f"{user} was banned by {ctx.author}",
color=random.randint(0, 0xFFFFFF),
)
embed.add_field(name="Reason:", value=reason)
try:
await user.ban(reason= reason)
except:
embed = discord.Embed(
title="An error occurred while trying to ban the user. Make sure ID is an existing ID that belongs to a user.",
color=0xE02B2B,
)
await ctx.send(embed=embed)
await user.send(f'you were banned by {ctx.author} from {ctx.guild.name} for {reason}')
@commands.command()
@has_permissions(ban_members=True)
async def hban(
self, context: Context, user_id: str, *, reason: str = "Not specified") -> None:
"""
Ban a user from server without user on server
:param context: The hybrid command context.
:param user_id: The ID of the user that should be banned.
:param reason: The reason for the ban. Default is "Not specified".
"""
try:
await self.bot.http.ban(user_id, context.guild.id, reason=reason)
user = self.bot.get_user(int(user_id)) or await self.bot.fetch_user(
int(user_id)
)
embed = discord.Embed(
description=f"{user} (ID: {user_id}) was banned by **{context.author}**!",
color=random.randint(0, 0xFFFFFF),
)
embed.add_field(name="Reason:", value=reason)
await context.send(embed=embed)
except Exception:
embed = discord.Embed(
description="An error occurred while trying to ban the user. Make sure ID is an existing ID that belongs to a user.",
color=0xE02B2B,
)
await context.send(embed=embed)
@commands.command()
@has_permissions(ban_members=True)
async def unban(self, context: Context, user_id: str, *, reason: str = "Not specified"):
"""
Unban a user from server
"""
try:
await self.bot.http.unban(user_id, context.guild.id, reason=reason)
user = self.bot.get_user(int(user_id)) or await self.bot.fetch_user(int(user_id))
embed = discord.Embed(
description=f"{user} (ID: {user_id}) was unbanned by {context.author}",
color=random.randint(0, 0xFFFFFF),
)
await context.send(embed=embed)
except Exception:
embed = discord.Embed(
description="An error occurred while trying to unban the user. Make sure ID is an existing ID that belongs to a user.",
color=0xE02B2B,
)
await context.send(embed=embed)
@commands.command()
@has_permissions(manage_messages=True)
async def delete(self, context: Context, amount: int) -> None:
"""
Delete a number of messages
"""
await context.send("Deleting messages...")
purged_messages = await context.channel.purge(limit=amount + 2)
embed = discord.Embed(
title=f"**{len(purged_messages)-1}** messages deleted",
description=f"in #{context.channel}",
color=random.randint(0, 0xFFFFFF),
).set_author(name=context.author.name, icon_url = context.author.avatar.url)
res = await self.bot.ch(server_id=context.guild.id)
channel = self.bot.get_channel(int(res))
await channel.send(embed=embed)
@commands.command()
@has_permissions(moderate_members=True)
async def timeout(self, ctx, user: discord.Member,seconds: int = 0, minutes: int = 0, hours: int = 0, days: int = 0, reason: str= "Not specified",) -> None:
"""
Timeout user for a time (s m h d reason)
"""
duration = datetime.timedelta(seconds=seconds, minutes=minutes, hours=hours, days=days)
embed = discord.Embed(
title=f'{user} has been timeout',
color = random.randint(0, 0xFFFFFF)
).set_author(name=ctx.author.name, icon_url = ctx.author.avatar.url)
embed.add_field(name="Reason:", value=reason)
embed.add_field(name="Time:", value=duration)
try:
await user.timeout(duration, reason=reason)
except:
embed = discord.Embed(
title="An error occurred while trying to timeout the user. Make sure ID is an existing ID that belongs to a user.",
color=0xE02B2B
)
await ctx.send(embed=embed)
@commands.command()
@commands.is_owner()
async def setwarnnumb(self, ctx,* , numb):
server_id = ctx.guild.id
row = self.bot.conwarn.execute("SELECT number FROM warnid WHERE server_id=?", (server_id,))
res = row.fetchone()
if res != None:
self.bot.conwarn.execute("DELETE FROM warnid WHERE server_id=?", (server_id,))
self.bot.conwarn.commit()
self.bot.conwarn.execute("INSERT INTO warnid(number, server_id) VALUES (?, ?)", (numb, server_id,))
self.bot.conwarn.commit()
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title='Warn number is set'
)
embed.add_field(name='current',value=numb)
await ctx.send(embed=embed)
@commands.command()
@commands.is_owner()
async def setwarnact(self, ctx,* , numb):
server_id = ctx.guild.id
row = self.bot.conwarn.execute("SELECT number FROM warnact WHERE server_id=?", (server_id,))
res = row.fetchone()
if res != None:
self.bot.conwarn.execute("DELETE FROM warnact WHERE server_id=?", (server_id,))
self.bot.conwarn.commit()
self.bot.conwarn.execute("INSERT INTO warnact(number, server_id) VALUES (?, ?)", (numb, server_id,))
self.bot.conwarn.commit()
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title='Warn action is choosen'
)
if numb == "1": name = "timeout"
elif numb == "2": name = "kick"
elif numb == "3": name = "ban"
else:
await ctx.send('list of actions:' '\n1 - timeout' '\n2 - kick' '\n3 - ban')
pass
embed.add_field(name='current',value=name)
await ctx.send(embed=embed)
@commands.command()
@commands.is_owner()
async def warnsettings(self, ctx):
server_id = ctx.guild.id
row = self.bot.conwarn.execute("SELECT number FROM warnid WHERE server_id=?", (server_id,))
res = row.fetchone()
row1 = self.bot.conwarn.execute("SELECT number FROM warnact WHERE server_id=?", (server_id,))
res1 = row1.fetchone()
if res1 == (1,): name = "timeout"
elif res1 == (2,): name = "kick"
elif res1 == (3,): name = "ban"
embed = discord.Embed(
color=random.randint(0, 0xFFFFFF),
title='Warn settings'
)
limit = str(res).replace("(","").replace(")","").replace(",","")
embed.add_field(name='current warn limit',value=limit)
embed.add_field(name='current warn action',value=name)
await ctx.send(embed=embed)
@commands.command()
@has_permissions(moderate_members=True)
async def warn(self, context = Context, user: discord.Member = None, *, reason: str = "Not specified") -> None:
"""
Warn a user. if it fourth warn, user get timeout
"""
s = 0
m = 0
h = 3
d = 0
duration = datetime.timedelta(seconds=s, minutes=m, hours=h, days=d)
user_id = user.id
server_id = context.guild.id
rows = self.bot.conwarn.execute("SELECT number FROM warnid WHERE server_id=?", (server_id,))
id = rows.fetchone()
try:
rows = self.bot.conwarn.execute("SELECT id FROM warn WHERE user_id=? AND server_id=? ORDER BY id DESC LIMIT 1", (user_id, server_id,))
results = rows.fetchone()
if results == None:
warn_id = 1
self.bot.conwarn.execute("INSERT INTO warn(id, user_id, server_id, reason) VALUES (?, ?, ?, ?)", (warn_id, user_id, server_id, reason,))
self.bot.conwarn.commit()
try:
await user.send(f'You have been warned by {context.author} reason: {reason}')
except:
await context.channel.send(f'<@{user_id}> You have been warned by {context.author} reason: {reason}')
elif results < id:
warn_id = results[0] + 1
self.bot.conwarn.execute("INSERT INTO warn(id, user_id, server_id, reason) VALUES (?, ?, ?, ?)", (warn_id, user_id, server_id, reason,))
self.bot.conwarn.commit()
try:
await user.send(f'You have been warned by {context.author} reason: {reason}')
except:
await context.channel.send(f'<@{user_id}> You have been warned by {context.author} reason: {reason}')
else:
row = self.bot.conwarn.execute("SELECT number FROM warnact WHERE server_id=?", (server_id,))
action = row.fetchone()
if action == (1,):
name = "timeouted"
await user.timeout(duration, reason=reason)
elif action == (2,):
name = "kicked"
await user.kick(reason=reason)
elif action == (3,):
name = "banned"
await user.ban(reason= reason)
await context.send(f"{user} has been {name}")
self.bot.conwarn.execute("DELETE FROM warn WHERE user_id=? AND server_id=?", (user_id, server_id,))
self.bot.conwarn.commit()
try:
if name == "timeouted":
await user.send(f'You get warn by {context.author} reason: {reason} you got {name} amout {duration}')
else:
await user.send(f'You get warn by {context.author} reason: {reason} you got {name}')
except:
if name == "timeouted":
await context.channel.send(f'<@{user.id}> you get warn by {context.author} reason: {reason} you got {name} amout {duration}')
else:
await context.channel.send(f'<@{user.id}> you get warn by {context.author} reason: {reason} you got {name}')
except:
await context.send('ERROR')
@commands.command()
@has_permissions(moderate_members=True)
async def warn_remove(self, context = Context, user: discord.Member = None) -> None:
"""
Remove all warns from user
"""
try:
user_id = user.id
server_id = context.guild.id
self.bot.conwarn.execute("DELETE FROM warn WHERE user_id=? AND server_id=?", (user_id, server_id,))
self.bot.conwarn.commit()
embed = discord.Embed(
title=f"All warns {user} has been deleted",
color=random.randint(0, 0xFFFFFF)
)
except:
embed = discord.Embed(
title="ERROR"
)
await context.send(embed=embed)
@commands.command()
@has_permissions(moderate_members=True)
async def warn_list(self, context = Context, user: discord.Member = None):
"""
List of user warns
"""
server_id = context.guild.id
user_id = user.id
rows = self.bot.conwarn.execute("SELECT user_id, server_id, reason FROM warn WHERE user_id=? AND server_id=?",(user_id, server_id,))
result = rows.fetchall()
result_list = []
for row in result:
result_list.append(row)
embed = discord.Embed(
title=f'Warns {user}',
color=random.randint(0, 0xFFFFFF)
)
description = ""
if len(result_list) == 0:
description = "This user has no warnings."
else:
for warning in result_list:
description += f"{1}. for reason: {warning[2]}\n"
embed.description = description
if user.avatar:
embed.set_thumbnail(url=user.avatar.url)
await context.send(embed=embed)
@commands.Cog.listener()
async def on_ready(self):
print('Moderation cog has been loaded')
async def setup(bot):
await bot.add_cog(Moderation(bot))

38
c/tasks.py Normal file
View File

@@ -0,0 +1,38 @@
import discord
from discord.ext import commands, tasks
from datetime import datetime
class Tasks(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
self.update_status.start()
global timestamp
timestamp = datetime.now()
print(f"start time {timestamp}")
@tasks.loop(seconds=60)
async def update_status(self):
dt = datetime.today()
delta = dt - timestamp
sec = delta.total_seconds()
minutes = int(sec) // 60
hours = int(sec) // 3600
days = int(sec) // 86400
if minutes >= 60:
minutes = (int(sec) - (hours * 3600)) // 60
if hours >= 24:
hours = (int(sec) - (days * 86400)) // 60 // 60
total = f"d:{days} h:{hours} m:{minutes}"
try:
await self.bot.status_up(total)
except:
print("can't set discord status")
@commands.Cog.listener()
async def on_ready(self):
print('Tasks cog has been loaded')
async def setup(bot):
await bot.add_cog(Tasks(bot))

28
c/testc.py Normal file
View File

@@ -0,0 +1,28 @@
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, Context
import time
import random
class Testc(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
@commands.command()
async def say(self, context: Context, *args):
"""
Repeats your message
"""
await context.send(allowed_mentions=discord.AllowedMentions(roles=False, users=False, everyone=False), content=" ".join(args))
await context.message.delete()
@commands.Cog.listener()
async def on_ready(self):
print('Testc cog has been loaded')
async def setup(bot):
await bot.add_cog(Testc(bot))