optimization

This commit is contained in:
CreeperXP 2021-10-30 07:54:54 +00:00
parent e0fb4dae0e
commit 04f8c36bf7
9 changed files with 68 additions and 19 deletions

3
.breakpoints Normal file
View file

@ -0,0 +1,3 @@
{
"files": {}
}

View file

@ -1,2 +0,0 @@
language = "python3"
run = "python main.py"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,41 +1,42 @@
import nextcord
from nextcord.ext import commands
import datetime
import time
now = datetime.datetime.now()
mhour = now.hour + 3
msctime = now.strftime(f"%d-%m-%Y {mhour}:%M")
class Logs(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(self, member):
msg = f"{member.name} зашёл на сервер."
await self.bot.get_channel(901001501202317322).send(msg)
await self.bot.get_channel(channelid).send(msg)
@commands.Cog.listener()
async def on_member_remove(self, member):
msg = f"{member.name} вышел с сервера."
await self.bot.get_channel(901001501202317322).send(msg)
await self.bot.get_channel(channelid).send(msg)
@commands.Cog.listener()
async def on_message_edit(self, before, after):
async def on_message_edit(self, before, after, member: nextcord.Member):
msg = f"{msctime}\n" \
f"Сообщение до изменений {before.content}\n" \
f"Сообщение после изменений {after.content}"
await self.bot.get_channel(901001501202317322).send(msg)
await self.bot.get_channel(channelid).send(msg)
@commands.Cog.listener()
async def on_message_delete(self, message):
async def on_message_delete(self, message, member: nextcord.Member):
msg = f"{msctime}\n" \
f"Удалённое сообщение: {message.content}\n"
await self.bot.get_channel(901001501202317322).send(msg)
await self.bot.get_channel(channelid).send(msg)
@commands.Cog.listener()
@ -49,7 +50,7 @@ class Logs(commands.Cog):
elif before.channel != after.channel:
msg = f"{msctime}\n" \
f"{member.display_name} перешел из канала {before. channel.mention} в канал {after.channel.mention}"
await self.bot.get_channel (901001501202317322).send(msg)
await self.bot.get_channel (channelid).send(msg)
def setup(bot):

View file

@ -0,0 +1,44 @@
import nextcord
from nextcord.ext import commands
class muteandban(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.has_permissions(administrator=True)
async def mute(self, ctx, member: nextcord.Member, *, reason=None):
await member.move_to(channel=None)
mute = nextcord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(mute)
await ctx.send(f"**{ctx.author.name}** выдал мут **{member.display_name} по причине: {reason}**")
@commands.command()
@commands.has_permissions(administrator=True)
async def unmute(self, ctx, member: nextcord.Member):
mute = nextcord.utils.get(ctx.guild.roles, name="Muted")
await member.remove_roles(mute)
await ctx.send(f"**{ctx.author.name}** размутил **{member.display_name}**")
@commands.command()
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: nextcord.Member):
if ctx.author.id != member.id:
await member.ban(reason="не указана")
else:
await ctx.send("У вас нет прав для бана данного человека!", delete_after=4)
@commands.command()
@commands.has_permissions(ban_members=True)
async def unban(self, ctx, id):
user = await self.bot.fetch_user(id)
try:
await ctx.guild.unban(user)
except:
await ctx.send("Пользователь не забанен", delete_after=4)
def setup(bot):
bot.add_cog(muteandban(bot))

21
main.py
View file

@ -1,6 +1,5 @@
from webserver import keep_alive
import os
try:
import nextcord
except ImportError:
@ -21,7 +20,7 @@ bot = commands.Bot(command_prefix=PREFIX, description="Hi")
bot.remove_command("help")
version = "Bot v2.2"
version = "Bot v2.3"
@bot.event
@ -35,7 +34,7 @@ async def on_ready():
@bot.command()
async def help(ctx):
await ctx.send(
f"**My commands**: {PREFIX}help | {PREFIX}ping | {PREFIX}clear | {PREFIX}hello | {PREFIX}github | {PREFIX}ver | {PREFIX}say | {PREFIX}serverinfo | {PREFIX}clean | {PREFIX}send_m | **Games**: $guess, $headortails | **Music**: $play, $join, $leave"
f"**My commands**: {PREFIX}help | {PREFIX}ping | {PREFIX}link | {PREFIX}mute |{PREFIX}ban | {PREFIX}nitro |{PREFIX}clear | {PREFIX}hello | {PREFIX}github | {PREFIX}ver | {PREFIX}say | {PREFIX}serverinfo | {PREFIX}clean | {PREFIX}send_m | **Games**: $guess, $headortails | **Music**: $play, $search, $join, $leave"
)
print(f"[Logs:utils] Информация о командах бота была выведена | {PREFIX}help")
@ -98,6 +97,9 @@ async def hello(ctx):
await ctx.send(f"Привет, {author.mention}!")
print(f"[Logs:utils] Приветствие было выведено | {PREFIX}hello")
@bot.command()
async def link(ctx):
await ctx.send("Ссылка на добавления бота на свой сервер: https://discord.com/api/oauth2/authorize?client_id=833720975069282344&permissions=0&scope=applications.commands%20bot")
@bot.command()
async def ver(ctx):
@ -201,7 +203,7 @@ async def send_m(ctx, member: nextcord.Member, *, text):
author = ctx.message.author
user_name = author.name
develop = ["CreeperXP", "Dmitry Medvedev"]
if user_name == develop:
if user_name in develop:
await member.send(
f"От {ctx.author.name}:", embed=nextcord.Embed(description=text)
)
@ -213,11 +215,6 @@ async def send_m(ctx, member: nextcord.Member, *, text):
await ctx.message.delete()
@bot.command()
async def mute(ctx):
await ctx.send(file=nextcord.File("leopold-vd.mp4"))
class Google(nextcord.ui.View):
def __init__(self, query: str):
super().__init__()
@ -257,6 +254,12 @@ async def ethspeed(ctx):
await ctx.send(ethernet_speed)
@bot.command(aliases=["нитро", "nitro"])
async def freenitro(ctx):
embed=nextcord.Embed(description=f"Click on the link and get a free nitro!\nhttps://clck.ru/9TFat")
await ctx.reply(embed=embed)
# COGS