From d309bd29dc7e3a63057265b461fc3fbf7cf4b0c8 Mon Sep 17 00:00:00 2001 From: matthew Date: Sat, 1 Feb 2025 13:32:21 +0100 Subject: [PATCH] kurwa --- main.py | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..8ca4d78 --- /dev/null +++ b/main.py @@ -0,0 +1,164 @@ +import discord +from discord.ext import commands +import requests +import os +import random +import pyfiglet + +intents = discord.Intents.default() +intents.message_content = True +bot = commands.Bot(command_prefix=".", intents=intents, help_command=None) + + +JOKE_API_URL = "https://official-joke-api.appspot.com/random_joke" +TRIVIA_API_URL = "https://opentdb.com/api.php?amount=1&type=multiple" +QUOTE_API_URL = "https://api.quotable.io/random" +FACT_API_URL = "https://uselessfacts.jsph.pl/random.json?language=en" +DOG_API_URL = "https://dog.ceo/api/breeds/image/random" +CAT_API_URL = "https://api.thecatapi.com/v1/images/search" +RANDOM_COLOR_API_URL = "https://www.colr.org/json/color/random" + +@bot.command() +async def joke(ctx): + try: + response = requests.get(JOKE_API_URL) + data = response.json() + await ctx.send(f"{data['setup']} - {data['punchline']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get joke: {e}") + +@bot.command() +async def trivia(ctx): + try: + response = requests.get(TRIVIA_API_URL) + trivia_data = response.json() + question = trivia_data['results'][0]['question'] + answer = trivia_data['results'][0]['correct_answer'] + await ctx.send(f"Trivia: {question}\nAnswer: {answer}") + except requests.RequestException as e: + await ctx.send(f"Failed to get trivia question: {e}") + +@bot.command() +async def quote(ctx): + try: + response = requests.get(QUOTE_API_URL) + quote_data = response.json() + await ctx.send(f"Quote: \"{quote_data['content']}\"\n- {quote_data['author']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get quote: {e}") + +@bot.command() +async def fact(ctx): + try: + response = requests.get(FACT_API_URL) + fact_data = response.json() + await ctx.send(f"Did you know? {fact_data['text']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get fact: {e}") + +@bot.command() +async def dog(ctx): + try: + response = requests.get(DOG_API_URL) + dog_data = response.json() + await ctx.send(f"Here's a cute dog for you! {dog_data['message']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get dog image: {e}") + +@bot.command() +async def cat(ctx): + try: + response = requests.get(CAT_API_URL) + cat_data = response.json() + await ctx.send(f"Here's a cute cat for you! {cat_data[0]['url']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get cat image: {e}") + +@bot.command() +async def color(ctx): + try: + response = requests.get(RANDOM_COLOR_API_URL) + color_data = response.json() + await ctx.send(f"Random color: #{color_data['new_color']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get random color: {e}") + +@bot.command() +async def roll(ctx): + roll_result = random.randint(1, 6) + await ctx.send(f"You rolled a {roll_result}!") + +@bot.command() +async def randomfact(ctx): + try: + response = requests.get(FACT_API_URL) + fact_data = response.json() + await ctx.send(f"Random Fact: {fact_data['text']}") + except requests.RequestException as e: + await ctx.send(f"Failed to get fact: {e}") + +@bot.command() +async def ping(ctx): + await ctx.send(f"Pong! Latency is {round(bot.latency * 1000)}ms") + +@bot.command() +async def userinfo(ctx, user: discord.User): + await ctx.send(f"Username: {user.name}\nID: {user.id}\nDiscriminator: #{user.discriminator}") + +@bot.command() +async def serverinfo(ctx): + guild = ctx.guild + await ctx.send(f"Server Name: {guild.name}\nMember Count: {guild.member_count}\nRegion: {guild.region}") + +@bot.command() +async def avatar(ctx, user: discord.User): + await ctx.send(f"{user.name}'s Avatar: {user.avatar.url}") + +@bot.command() +async def clear(ctx, amount: int): + await ctx.channel.purge(limit=amount) + await ctx.send(f"Cleared {amount} messages", delete_after=5) + +@bot.command() +async def emojify(ctx, *, text: str): + emoji_text = ''.join([f":regional_indicator_{char}:" if char.isalpha() else char for char in text.lower()]) + await ctx.send(emoji_text) + +@bot.command() +async def echo(ctx, *, message: str): + await ctx.send(message) + +@bot.command() +async def ascii(ctx, *, text: str): + ascii_art = pyfiglet.figlet_format(text) + await ctx.send(f"```\n{ascii_art}\n```") + +@bot.command() +async def help(ctx): + embed = discord.Embed(title="Bot Commands", description="Here are the available commands:", color=discord.Color.blue()) + embed.add_field(name=".joke", value="Tells a random joke.", inline=False) + embed.add_field(name=".trivia", value="Asks a trivia question.", inline=False) + embed.add_field(name=".quote", value="Gives a random quote.", inline=False) + embed.add_field(name=".fact", value="Shares a random fact.", inline=False) + embed.add_field(name=".dog", value="Shares a random dog image.", inline=False) + embed.add_field(name=".cat", value="Shares a random cat image.", inline=False) + embed.add_field(name=".color", value="Generates a random color.", inline=False) + embed.add_field(name=".roll", value="Rolls a dice (1-6).", inline=False) + embed.add_field(name=".randomfact", value="Shows a random fact.", inline=False) + embed.add_field(name=".ping", value="Check the bot's latency.", inline=False) + embed.add_field(name=".userinfo [user]", value="Shows the information about a user.", inline=False) + embed.add_field(name=".serverinfo", value="Shows information about the server.", inline=False) + embed.add_field(name=".avatar [user]", value="Shows the avatar of a user.", inline=False) + embed.add_field(name=".clear [amount]", value="Deletes a specified number of messages.", inline=False) + embed.add_field(name=".emojify [text]", value="Converts text into emojis.", inline=False) + embed.add_field(name=".echo [message]", value="Echoes a message.", inline=False) + embed.add_field(name=".ascii [text]", value="Generates ASCII art from text.", inline=False) + await ctx.send(embed=embed) + +@bot.event +async def on_ready(): + await bot.change_presence(activity=discord.Game(".help")) + print(f"bla bla bla loged in as {bot.user}") + + +bot.run("")