Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0a5c9cc0b | ||
|
|
8ce5412f9d |
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
.env
|
.env
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyd
|
*.pyd
|
||||||
|
*__pycache__/
|
||||||
poetry.lock
|
poetry.lock
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import asyncio
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
@@ -21,32 +24,54 @@ intents = discord.Intents.all()
|
|||||||
intents.members = True
|
intents.members = True
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
|
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix="?", description=description, intents=intents)
|
|
||||||
|
|
||||||
|
|
||||||
libs = [
|
libs = [
|
||||||
"jishaku",
|
"jishaku",
|
||||||
|
"lib.mod",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
def get_prefix(bot, message):
|
||||||
async def on_ready():
|
|
||||||
|
|
||||||
|
prefixes = ["?"]
|
||||||
|
return commands.when_mentioned_or(*prefixes)(bot, message)
|
||||||
|
|
||||||
|
|
||||||
|
class Bot(commands.Bot):
|
||||||
|
|
||||||
|
async def on_ready(self):
|
||||||
for lib in libs:
|
for lib in libs:
|
||||||
|
try:
|
||||||
await bot.load_extension(lib)
|
await bot.load_extension(lib)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[!] Failed to load extension: {lib}")
|
||||||
|
traceback.print_exc()
|
||||||
print(f"\n[^] Loaded {len(libs)} extensions loaded successfully.")
|
print(f"\n[^] Loaded {len(libs)} extensions loaded successfully.")
|
||||||
|
|
||||||
# for guild in bot.guilds:
|
# for guild in bot.guilds:
|
||||||
# await bot.tree.sync(guild=discord.Object(id=guild.id))
|
# await bot.tree.sync(guild=discord.Object(id=guild.id))
|
||||||
# print(f"[^] Sync'd application commands to {len(bot.guilds)} servers")
|
# print(f"[^] Sync'd application commands to {len(bot.guilds)} servers")
|
||||||
|
|
||||||
print(f"[*] Logged in as {bot.user} (ID: {bot.user.id})")
|
print(f"[*] I am {bot.user} (ID: {bot.user.id})")
|
||||||
game = discord.Game(name="https://traps.moe", activity=random.randint(0, 3))
|
game = discord.Game(name="https://traps.moe", activity=random.randint(0, 3))
|
||||||
await bot.change_presence(status=discord.Status.online, activity=game)
|
await bot.change_presence(status=discord.Status.online, activity=game)
|
||||||
print("------")
|
print("------")
|
||||||
|
|
||||||
|
|
||||||
|
if sys.platform == "Linux":
|
||||||
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
else:
|
||||||
|
asyncio.set_event_loop_policy(winloop.EventLoopPolicy())
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
|
||||||
|
bot = Bot(
|
||||||
|
command_prefix=get_prefix,
|
||||||
|
description=description,
|
||||||
|
intents=intents,
|
||||||
|
loop=loop,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def joined(ctx, member: discord.Member):
|
async def joined(ctx, member: discord.Member):
|
||||||
"""Says when a member joined."""
|
"""Says when a member joined."""
|
||||||
@@ -64,9 +89,4 @@ async def first_slash(ctx):
|
|||||||
await ctx.send("You executed the slash command!")
|
await ctx.send("You executed the slash command!")
|
||||||
|
|
||||||
|
|
||||||
if sys.platform == "Linux":
|
|
||||||
uvloop.install()
|
|
||||||
else:
|
|
||||||
winloop.install()
|
|
||||||
|
|
||||||
bot.run(TOKEN)
|
bot.run(TOKEN)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
def check_bot():
|
||||||
|
async def predicate(ctx):
|
||||||
|
return not ctx.author.bot
|
||||||
|
return commands.check(predicate)
|
||||||
|
|
||||||
|
async def check(ctx):
|
||||||
|
ids = [232948417087668235, 124316478978785283, 131131701148647424]
|
||||||
|
return ctx.author.id in ids
|
||||||
|
def _check():
|
||||||
|
return commands.check(check)
|
||||||
|
|
||||||
|
def get_user(message, user):
|
||||||
|
try:
|
||||||
|
member = message.mentions[0]
|
||||||
|
except:
|
||||||
|
member = message.guild.get_member_named(user)
|
||||||
|
if not member:
|
||||||
|
try:
|
||||||
|
member = message.guild.get_member(int(user))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if not member:
|
||||||
|
return None
|
||||||
|
return member
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
from lib.checks import get_user
|
||||||
|
|
||||||
|
class Mod(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@commands.command(aliases=['hban'], pass_context=True)
|
||||||
|
async def hackban(self, ctx, user_id: int):
|
||||||
|
author = ctx.message.author
|
||||||
|
guild = author.guild
|
||||||
|
|
||||||
|
user = guild.get_member(user_id)
|
||||||
|
if user is not None:
|
||||||
|
return await ctx.invoke(self.ban, user=user)
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self.bot.http.ban(user_id, guild.id, 0)
|
||||||
|
await ctx.send(f'Banned user: {user_id}')
|
||||||
|
except discord.NotFound:
|
||||||
|
await ctx.send('Could not find user. ')
|
||||||
|
|
||||||
|
except discord.errors.Forbidden:
|
||||||
|
await ctx.send('Could not ban user. Not enough permissions.')
|
||||||
|
|
||||||
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@commands.command(aliases=['p'], pass_context=True, no_pm=True)
|
||||||
|
async def purge(self, ctx, msgs: int, members="everyone", *, txt=None):
|
||||||
|
@property
|
||||||
|
def destination(self):
|
||||||
|
return self.context.message.author if self.bot.pm_help else self.context.message.channel
|
||||||
|
|
||||||
|
'''
|
||||||
|
Purge last n messages or nmessages with a word. Requires Manage Messages permission. [p]help purge for more info.
|
||||||
|
|
||||||
|
Ex:
|
||||||
|
|
||||||
|
[p]purge 20 - deletes the last 20 messages in a channel sent by anyone.
|
||||||
|
[p]purge 20 everyone stuff - deletes any messages in the last 20 messages that contain the word 'stuff'.
|
||||||
|
[p]purge 20 @appu1232 - deletes any messages in the last 20 messages that were sent by appu1232.
|
||||||
|
[p]purge 20 "@appu1232, LyricLy, 435254873976547426" hello - deletes any messages in the last 20 messages that were sent by appu1232, LyricLy or thecommondude that contain the word 'stuff'.
|
||||||
|
'''
|
||||||
|
await ctx.message.delete()
|
||||||
|
content = f'I deleted {msgs} message(s) 👻'
|
||||||
|
member_object_list = []
|
||||||
|
if members != "everyone":
|
||||||
|
member_list = [x.strip() for x in members.split(",")]
|
||||||
|
for member in member_list:
|
||||||
|
if "@" in member:
|
||||||
|
member = member[3 if "!" in member else 2:-1]
|
||||||
|
if member.isdigit():
|
||||||
|
member_object = ctx.guild.get_member(int(member))
|
||||||
|
else:
|
||||||
|
member_object = ctx.guild.get_member_named(member)
|
||||||
|
if not member_object:
|
||||||
|
return await ctx.send(self.bot.bot_prefix + "Invalid user.")
|
||||||
|
else:
|
||||||
|
member_object_list.append(member_object)
|
||||||
|
|
||||||
|
if msgs < 10000:
|
||||||
|
async for message in ctx.message.channel.history(limit=msgs):
|
||||||
|
try:
|
||||||
|
if txt:
|
||||||
|
if not txt.lower() in message.content.lower():
|
||||||
|
continue
|
||||||
|
if member_object_list:
|
||||||
|
if not message.author in member_object_list:
|
||||||
|
continue
|
||||||
|
|
||||||
|
await message.delete()
|
||||||
|
except discord.Forbidden:
|
||||||
|
await ctx.send("I do not have permission to delete other users messages.")
|
||||||
|
else:
|
||||||
|
await ctx.send('Too many messages to delete. Enter a number < 10000')
|
||||||
|
|
||||||
|
await ctx.send(content=content,delete_after=15.0)
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Mod(bot))
|
||||||
Reference in new issue
Block a user