import disnake
from disnake.ext import commands
import discord
from discord.ext import commands
import pycord
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='-', intents=intents)
CENSORED_WORDS = ["ptr", "hgf", "dwad", "wwww"]
@commands.has_permissions(kick_members=True, administrator=True)
@bot.event
async def on_ready():
print(f"Bot is ready. Logged in as {bot.user.name}")
@bot.event
async def on_member_join():
role = await disnake.utils.get(guild_id=member.guil.id, role_id=1087826999952814120)
channel - member.guild.system_channel
embed = disnake.Embed(
title="Новий учасник!",
description=f"{member.name}#{member.discriminator}",
color=FFFF00
)
await member.add_roles(role)
await channel.send(embed=embed)
@bot.event
async def on_message(message):
await bot.process_commands(message)
for content in message.content.split(","):
for censored_word in CENSORED_WORDS:
if content.lower == censored_word:
await message.delete()
await message.channel.send(f"{message.autor} аяяй!")
@bot.command()
async def hello(ctx):
await ctx.send("Hello, I`m work!")
@bot.command()
async def ban(ctx, member: discord.Member):
if ctx.author.guild_permissions.administrator:
await member.ban()
await ctx.send(f"{member.name} has banned")
else:
await ctx.send("You don`t have permissions to use this command!")
@bot.command()
async def kick(ctx, member: discord.Member, reason="Порушення правил!"):
await ctx.send(f"{ctx.author.mention} kicked {member.mention}", delete_after=5)
await member.kick(reason=reason)
await ctx.message.delete()
@bot.command()
async def mute(ctx, member: discord.Member):
if ctx.author.guild_permissions.administrator:
await mute(ctx, member)
await ctx.send(f"{member.name} has muted.")
else:
await ctx.send("You don`t have permissions to use this command!")
@bot.command()
async def speedtest(ctx):
st = speedtest.Speedtest()
download_speed = st.download() / 1024 / 1024
upload_speed = st.upload() / 1024 / 1024
await ctx.send(f"Speed download: {download_speed:.2f} Мбіт/с")
await ctx.send(f"Speed upload: {upload_speed:.2f} Мбіт/с")
@bot.command()
async def ping(ctx):
response_time = pythonping.ping('google.com').rtt_avg_ms
await ctx.send(f"Ping to google.com: {response_time:.2f} ms")
@bot.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, reason=None):
await member.send(f"You have warn {ctx.guild.name}. Reason: {reason}")
await ctx.send(f"User {member.mention} has warn. Reason: {reason}")
@warn.error
async def warn_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("please ping the user.")
elif isinstance(error, commands.MissingPermissions):
await ctx.send("You don`t have permissions to use this command.")
bot.run("token")