Skip to content

Instantly share code, notes, and snippets.

@Zomatree
Last active December 1, 2019 00:24
Show Gist options
  • Save Zomatree/343197c63aa215a0e9efa6e4c48f8d29 to your computer and use it in GitHub Desktop.
Save Zomatree/343197c63aa215a0e9efa6e4c48f8d29 to your computer and use it in GitHub Desktop.
fucking hell to make
(lambda:[globals().update(set_var=lambda k, v: globals().__setitem__(k, v)),set_var("_import", lambda module: set_var(module, __import__(module))),_import("config"),_import("discord"),_import("random"),_import("asyncio"),_import("youtube_dl"),_import("math"),_import("re"),_import("logging"),_import("sqlite3"),set_var("TOKEN", config.token),set_var("commands", __import__("discord.ext", globals(), locals(), ["commands"]).commands),set_var("regex", r"(-?\d+)x\^2([+-]\d+)x([+-]\d+)"),setattr(youtube_dl.utils, "bug_reports_message", lambda: ''),set_var("ytdl_format_options", {'format': 'bestaudio/best','outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s','restrictfilenames': True,'noplaylist': True,'nocheckcertificate': True,'ignoreerrors': False,'logtostderr': False,'quiet': True,'no_warnings': True,'default_search': 'auto','source_address': '0.0.0.0'}),set_var("ffmpeg_options", {'options': '-vn'}),set_var("ytdl", youtube_dl.YoutubeDL(ytdl_format_options)),set_var("CustomContext", type("LShiftContext", (commands.Context,), {"__lshift__": lambda self, other: [asyncio.run_coroutine_threadsafe(self.send(other), self.bot.loop), None][1]})),set_var("bot", type("Bot", (commands.Bot,), {"get_context": lambda self, message, cls=None: super(commands.Bot, self).get_context(message, cls=CustomContext),"on_ready": asyncio.coroutine(lambda self: print("Ready!")),"db": sqlite3.connect('todo.db')})(config.prefix, help_command=type("HelpCommand", (commands.MinimalHelpCommand,), {"get_command_signature": lambda self, command:f'{self.clean_prefix}{command.qualified_name} {command.signature}'})())),logging.basicConfig(level=logging.INFO),setattr(bot, "owner_id", 285130711348805632),bot.load_extension("jishaku"),bot.command(name="hello")(asyncio.coroutine(lambda ctx: ctx.send("hello world"))),set_var("mention", bot.command(name="mention")(asyncio.coroutine(lambda ctx, user: ()))),set_var("temp_command", lambda ctx, user:ctx.send(user.mention)),setattr(temp_command, "__annotations__", {"user": discord.Member}),setattr(temp_command, "_doc__", "mentions someone"),setattr(mention, "callback", temp_command),mention.error(asyncio.coroutine(lambda ctx, error: ctx.send("error" if not isinstance(error, commands.MissingRequiredArgument) else "no `user` arg, please pass one, thank u"))),bot.command(name="8ball")(asyncio.coroutine(lambda ctx, *, args:ctx.send(random.choice(["yes","no","idk","shrug"])))),bot.command(name="quad")(asyncio.coroutine(lambda ctx, *,args:ctx.send([set_var("match", re.match(regex, args)),f"{-int(match[2])+math.sqrt((int(match[2])**2)-4*int(match[1])*int(match[3]))/2*int(match[1])}, {-int(match[2])-math.sqrt((int(match[2])**2)-4*int(match[1])*int(match[3]))/2*int(match[1])}"][-1]))),set_var("purge", bot.command(name="purge")(asyncio.coroutine(lambda ctx, amount: ()))),set_var("temp_purge", (lambda ctx, amount: [bot.loop.create_task(ctx.channel.purge(limit = amount+1)),ctx.send(f"purged {amount}", delete_after=10)][1])),setattr(temp_purge, "__annotations__", {"amount": int}),setattr(purge, "callback", asyncio.coroutine(temp_purge)),purge.error(asyncio.coroutine(lambda ctx, error: ctx.send(f"```\n{error}\n```"))),set_var("YTDLSource", type("YTDLSource", (discord.PCMVolumeTransformer,), {"__init__": lambda self, source, *, data, volume=0.5: [super(type(self), self).__init__(source, volume),setattr(self, "data", data),setattr(self, "title", data.get('title')),None][-1],"from_url": classmethod(lambda cls, url, *, loop=None, stream=None:[set_var("loop", loop or asyncio.get_event_loop()),set_var("data", ytdl.extract_info(url, download=not stream)),set_var("data", data['entries'][0] if "entries" in data else data),set_var("filename", data['url'] if stream else ytdl.prepare_filename(data)),cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)][-1])})),set_var("join", bot.command(name="join")(asyncio.coroutine(lambda ctx, *, channel: 0))),set_var("temp_join", lambda ctx, *, channel=None: [set_var("channel", channel or ctx.author.voice.channel),ctx.voice_client.move_to(channel) if ctx.voice_client is not None else channel.connect()][1]),setattr(temp_join, "__annotations__", {"channel": discord.VoiceChannel}),setattr(join, "callback", asyncio.coroutine(temp_join)),set_var("play", bot.command(name="play")(asyncio.coroutine(lambda ctx, *, url: [set_var("player", YTDLSource.from_url(url, loop=bot.loop, stream=True)),ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None),ctx.send('Now playing: {}'.format(player.title))][-1]))),bot.command(name="volume")(asyncio.coroutine(lambda ctx, volume: [ctx.send("Not connected to a voice channel."),setattr(ctx.voice_client.source, "volume", int(volume) / 100),ctx.send("Changed volume to {}%".format(volume))][0 if ctx.voice_client is None else -1])),bot.command(name="stop")(asyncio.coroutine(lambda ctx: ctx.voice_client.disconnect())),play.before_invoke(asyncio.coroutine(lambda ctx: (ctx.author.voice.channel.connect() if ctx.author.voice else ctx.send("You are not connected to a voice channel."))if ctx.voice_client is None else ctx.voice_client.stop() if ctx.voice_client.is_playing() else None)),set_var("todo", bot.group(name="todo", invoke_without_command=True)(asyncio.coroutine(lambda ctx:ctx.send_help(ctx.command)))),todo.command(name="add")(asyncio.coroutine(lambda ctx, *, message:[set_var("cur", bot.db.cursor()),cur.execute("""INSERT INTO "todo" VALUES (?, ?)""", (ctx.author.id, message)),bot.db.commit(),ctx.send(f"Added {message} to your todo list.")][-1])),todo.command(name="list")(asyncio.coroutine(lambda ctx: [set_var("embed", discord.Embed(description="\n".join([f"{i+1}. {x[0]}" for i,x in enumerate(bot.db.cursor().execute("""SELECT Message FROM todo WHERE MemberID=?""", (ctx.author.id,)))]))),embed.set_author(name = str(ctx.author), icon_url = str(ctx.author.avatar_url_as(format="jpg", static_format="jpg"))),ctx.send(embed = embed)][-1])),bot.run(TOKEN)])()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment