from instaloader import Instaloader import os import wavelink import nextcord from nextcord.ext import commands, tasks import asyncio import random from pixabay import image import aiohttp import urllib import json from bs4 import BeautifulSoup import requests from datetime import datetime import aiosqlite import asyncpraw import humanfriendly import pytz from itertools import cycle import io import yt_dlp from PIL import Image, ImageDraw, ImageFont L = Instaloader() intents = nextcord.Intents.all() TOKEN = "MTE3NTc3MjkxMzk4MzU2MTczOA.GmmTN6.eImIaItelRzD7t2TghLjzCV8sKQUbrA-zsAJDY" APIPIXABAY_KEY = "42789839-5784c8844b8f3adac5c09d562" bot = commands.Bot(command_prefix='s!', intents=intents) intents.presences = True voice_clients = {} answered_suggestions = [] current_question = None current_answer = None questionactive = False yt_dl_opts = {'format': 'bestaudio/best'} ytdl = yt_dlp.YoutubeDL(yt_dl_opts) ffmpeg_options = {'options': "-vn"} bot_status = cycle(["s!help", "PornHub", "sky's the best", "s!syntax", "i love djfoot", "with ur mom", "with djfoot", "inter vs psg", "with Agge", "with ur mom", "with pinch's mother"]) @tasks.loop(seconds=15) async def change_status(): await bot.change_presence(activity=nextcord.Game(next(bot_status))) questions = [ ("What is the capital of Botswana?", "Gaborone"), ("What is the largest planet in our solar system?", "Jupiter"), ("Who painted the Mona Lisa?", "Leonardo da Vinci"), ("Which country is known as the Land of the Rising Sun?", "Japan"), ("What does KFC stand for?", "Kentucky Fried Chicken"), ("Who made more money? Coca-Cola or Pepsi?", "Coca-Cola"), ("What ex-planet in our solar system isn't considered a planet anymore?", "Pluto"), ("When was Footcord made? (24 may 2023) | (17 june 2023) | (19 june 2023)", "19 june 2023"), ("Who is known as the father of modern physics?", "Albert Einstein"), ("What is the chemical symbol of water?", "H2O"), ("Which planet is known as the Red Planet?", "Mars"), ("What's the tallest mammal on Earth?", "Giraffe") ] @bot.event async def on_ready(): print("Bot is online.") default_file_path = "home/container/xslayder-coca-cola.gif" try: if default_file_path.lower().endswith(('.gif')): with open(default_file_path, 'rb') as avatar: await bot.user.edit(avatar=avatar.read()) else: print("Please provide a valid GIF file path.") except Exception as e: print(f"Error: {e}") change_status.start() bot.db = await aiosqlite.connect("s12220_bank.db") await asyncio.sleep(3) async with bot.db.cursor() as cursor: await cursor.execute("CREATE TABLE IF NOT EXISTS bank (wallet INTEGER, bank INTEGER, maxbank INTEGER, user INTEGER)") await cursor.execute("CREATE TABLE IF NOT EXISTS suggestions (id INTEGER PRIMARY KEY AUTOINCREMENT, author_id INTEGER, suggestion_text TEXT, status TEXT DEFAULT 'pending')") await bot.db.commit() print("Connected to database.") guild = bot.get_guild(1120312508184530954) category = guild.categories[0] existing_channel = next((c for c in category.voice_channels if c.name.startswith("Members: ")), None) if existing_channel: await update_member_count(existing_channel, guild) #else: #channel = await category.create_voice_channel("Members: 0", position=0) await guild.chunk() API_KEY = "1b2ec024e31642568ad203730240103" @bot.command() async def rng(ctx, min_num: int, max_num: int): """Generates a random number""" if min_num >= max_num: await ctx.send("Minimum number must be less than the max number.") return number = random.randint(min_num, max_num) await ctx.send(f"The number generated is {number}.") @bot.command() async def weather(ctx: commands.Context, *, city: str): """Used to check the weather of a city""" url = "https://api.weatherapi.com/v1/current.json" params = { "key": API_KEY, "q": city } async with aiohttp.ClientSession() as session: async with session.get(url, params=params) as res: data = await res.json() location = data["location"]["name"] temp_c = data["current"]["temp_c"] temp_f = data["current"]["temp_f"] humidity = data["current"]["humidity"] wind_kph = data["current"]["wind_kph"] wind_mph = data["current"]["wind_mph"] condition = data["current"]["condition"]["text"] image_url = "http:" + data["current"]["condition"]["icon"] embed = nextcord.Embed(title=f"Weather for {location}", description=f"The condition in **{location}** is **{condition}**") embed.add_field(name="Temperature", value=f"C: {temp_c} | F: {temp_f}") embed.add_field(name="Humidity", value=f"{humidity}%") embed.add_field(name="Wind Speeds", value=f"KPH: {wind_kph} | MPH: {wind_mph}") embed.set_thumbnail(url=image_url) await ctx.send(embed=embed) @bot.command() async def instapic(ctx, username): """Downloads someone's instagram profile picture""" try: await ctx.send(f"**Downloading {username}'s Instagram profile picture. Please wait..**") L.download_profile(username, profile_pic_only=True) folder_path = f'/home/container/{username}' if os.path.exists(folder_path): for filename in os.listdir(folder_path): file_path = os.path.join(folder_path, filename) if filename.endswith(".jpg") or filename.endswith(".jpeg"): await ctx.send(file=nextcord.File(file_path)) os.remove(file_path) for file in os.listdir(folder_path): file_path = os.path.join(folder_path, file) try: if os.path.isfile(file_path): os.unlink(file_path) except Exception as e: print(f"Error: {e}") os.rmdir(folder_path) await ctx.send(f"{ctx.author.mention}") else: await ctx.send("Folder not found.") except Exception as e: print(f"Error: {e}") await ctx.send(f"Error: {e}") @bot.command() async def stealemoji(ctx, url:str, *, name): """Steals an emoji from a different server (mods only)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return guild = ctx.guild async with aiohttp.ClientSession() as ses: async with ses.get(url) as r: try: imgOrGif = io.BytesIO(await r.read()) bValue = imgOrGif.getvalue() if r.status in range(200, 299): emoji = await guild.create_custom_emoji(image=bValue, name=name) await ctx.send(f"Emoji {emoji} ({name}) has been added.") await ses.close() else: await ctx.send(f"Couldn't add emoji. | {r.status}") except nextcord.HTTPException: await ctx.send("Error occurred while adding the emoji. Either the file is too big, or you don't have the permissions to use this command.") @bot.event async def on_message_delete(message): if message.author.bot: return if message.attachments: attachment_url = message.attachments[0].url embed = nextcord.Embed( title=f"{message.author.name} has deleted an image | {message.author.id}", description=f"**Deleted image:**" ) embed.set_image(url=attachment_url) else: embed = nextcord.Embed( title=f"{message.author.name} has deleted a message | {message.author.id}", description=f"**Deleted message:** {message.content}" ) channel = bot.get_channel(1213246068251426897) await channel.send(embed=embed) @bot.event async def on_message_edit(before, after): if before.author.bot or after.author.bot: return before_embeds = before.embeds after_embeds = after.embeds if not before_embeds and not after_embeds: channel = bot.get_channel(1213246068251426897) embed = nextcord.Embed( title=f"{before.author.name} has edited a message | {before.author.id}", description=f"**Before message:** {before.content}n**After message:** {after.content}" ) await channel.send(embed=embed) @bot.command() async def mute(ctx, member: nextcord.Member, time, *, reason): """Mutes someone (mods only)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return time = humanfriendly.parse_timespan(time) await member.edit(timeout=nextcord.utils.utcnow() + datetime.timedelta(seconds=time)) await ctx.send(f"{member.display_name} has been muted for {time} seconds by {ctx.author.mention}, reason: {reason}.") @bot.command() async def unmute(ctx, member: nextcord.Member, *, reason): """Unmutes someone (mods only)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return await member.edit(timeout=None) await ctx.send(f"{member.display_name} has been unmuted by {ctx.author.mention}, reason: {reason}.") @bot.command() async def play(ctx: commands.Context, *, search: str): """Plays videos from YouTube in a voice channel""" if not ctx.voice_client: vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player) elif not ctx.author.voice_client: return await ctx.send("You first have to join a voice chat in order to use the bot!") else: vc: wavelink.Player = ctx.voice_client track = await wavelink.YouTubeTrack.from_url(search) await vc.play(search) @bot.slash_command(name="repeat", description="Repeats whatever the user says") async def repeat(ctx, message: str): await ctx.send(message) @bot.command() async def av(ctx, member: nextcord.Member = None): """Shows someone's avatar""" if member is None: member = ctx.author member_avatar = member.avatar.url avaembed = nextcord.Embed(title=f"{member.name}'s Avatar - Requested by {ctx.author.name}") avaembed.set_image(url=member_avatar) await ctx.send(embed=avaembed) ytdl = yt_dlp.YoutubeDL({'format': 'bestaudio'}) @bot.command() async def members(ctx): """Shows the number of members""" member_count = len(ctx.guild.members) await ctx.send(f"This server has {member_count} members.") @bot.listen("on_message") async def play_music(ctx): if ctx.author.bot: return if ctx.content.startswith("s!play"): """Plays videos from YouTube in a voice channel""" try: voice_state = ctx.author.voice if voice_state and voice_state.channel: voice_client = await voice_state.channel.connect() voice_clients[ctx.guild.id] = voice_client else: await ctx.channel.send("You have to be connected to a voice channel in order to use this.") return except Exception as err: await ctx.channel.send("Error occurred while connecting to voice channel.") print(f"Error occurred while connecting to voice channel: {err}") return try: url = ctx.content.split()[1] loop = asyncio.get_event_loop() data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False)) if 'entries' in data: data = data['entries'][0] song_title = data['title'] song_url = data['url'] player = nextcord.FFmpegPCMAudio(song_url, **ffmpeg_options) if ctx.guild.id in voice_clients: voice_clients[ctx.guild.id].play(player) else: await ctx.channel.send("The bot is not connected to a voice channel.") return username = ctx.author.name await ctx.channel.send(f"Now playing '{song_title}', requested by {username}.") except Exception as err: print(f"Error occurred while playing the song: {err}") await ctx.channel.send("Failed to play the song.") @bot.command() async def pause(ctx): """Pauses the bot from playing the video in the voice channel""" try: voice_state = ctx.author.voice if not voice_state or voice_state.channel != voice_clients[ctx.guild.id].channel: await ctx.channel.send("You are not in the same voice channel as the bot.") return if ctx.guild.id in voice_clients: voice_clients[ctx.guild.id].pause() await ctx.channel.send(f"{ctx.author.name} has paused the video.") else: await ctx.channel.send("The bot is not connected to a voice channel.") except Exception as err: print(f"Error occurred while pausing: {err}") @bot.command() async def resume(ctx): """Resumes playing the video in the voice channel""" try: voice_state = ctx.author.voice if not voice_state or voice_state.channel != voice_clients[ctx.guild.id].channel: await ctx.channel.send("You are not in the same voice channel as the bot.") return if ctx.guild.id in voice_clients: voice_clients[ctx.guild.id].resume() await ctx.channel.send(f"{ctx.author.name} has resumed the video.") else: await ctx.channel.send("The bot is not connected to a voice channel.") except Exception as err: print(f"Error occurred while resuming: {err}") @bot.command() async def stop(ctx): """Remove the bot from the voice channel""" try: voice_state = ctx.author.voice if not voice_state or voice_state.channel != voice_clients[ctx.guild.id].channel: await ctx.channel.send("You are not in the same voice channel as the bot.") return if ctx.guild.id in voice_clients: voice_clients[ctx.guild.id].stop() await voice_clients[ctx.guild.id].disconnect() del voice_clients[ctx.guild.id] await ctx.channel.send(f"{ctx.author.name} has removed the bot from the voice chat.") else: await ctx.channel.send("The bot is not connected to a voice channel.") except Exception as err: print(f"Error occurred while stopping: {err}") @bot.command() async def banner(ctx, user: nextcord.Member = None): """Shows someone's banner""" if user is None: user = ctx.author req = await bot.http.request(nextcord.http.Route("GET", f"/users/{user.id}")) banner_id = req.get("banner") if banner_id: if banner_id.startswith("a_"): banner_url = f"https://cdn.discordapp.com/banners/{user.id}/{banner_id}.gif?size=1024" else: banner_url = f"https://cdn.discordapp.com/banners/{user.id}/{banner_id}?size=1024" await ctx.send(f"{user.name}'s banner requested by {ctx.author.name}.n{banner_url}") else: await ctx.send(f"{user.name} does not have a banner.") async def update_member_count(channel, guild): await guild.chunk() member_count = len(guild.members) await channel.edit(name=f"Members: {member_count}") @bot.event async def on_member_join(member): welcome_embed = nextcord.Embed( title=f"Welcome to our server, {member.name}!", description=f"You are one of us now, {member.mention}!nPlease don't forget to:n#1: Be respectful to everyone.n#2: Make sure to read the rules.n#3: Have fun!", color=nextcord.Color.blurple() ) if member.avatar: welcome_embed.set_thumbnail(url=member.avatar.url) await bot.get_channel(1121541613991251968).send(embed=welcome_embed) guild = member.guild category = guild.categories[0] channel = next((c for c in category.voice_channels if c.name.startswith("Members: ")), None) if channel: await update_member_count(channel, guild) @bot.event async def on_member_remove(member): guild = member.guild category = guild.categories[0] channel = next((c for c in category.voice_channels if c.name.startswith("Members: ")), None) if channel: await update_member_count(channel, guild) reddit = asyncpraw.Reddit( client_id="wz2oGjuKQxUqJpU-ED7soQ", client_secret="J28jQ47JHTxtYFoIlNohy_6fHetPaQ", user_agent="SopBot/1.0 by PetardaBUM1997", ) @bot.command() async def sop(ctx): """Smash or pass command""" subreddit = await reddit.subreddit("jerkofftoceleb") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Smash or Pass?", description="Picture taken from **r/jerkofftoceleb**") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def msop(ctx): """Smash or pass command, but with men""" subreddit = await reddit.subreddit("LadyBoners") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Smash or Pass?", description="Picture taken from **r/LadyBoners**") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def tsop(ctx): """Smash or pass command, but with trans people""" subreddit = await reddit.subreddit("GoneWildTrans") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Smash or Pass?", description="Picture taken from **r/GoneWildTrans**") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def porn(ctx): """Sends porn pictures""" subreddit = await reddit.subreddit("nsfw") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Porn image - taken from **r/nsfw**", description="Are you horny? Looking for that sweet sweet quality **porno?** Well my friend, you're in luck. Keep jerking off, you disgusting animal!") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def mporn(ctx): """Sends porn pictures of men""" subreddit = await reddit.subreddit("MenGW") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Porn image - taken from **r/MenGW**", description="Are you horny? Looking for that sweet sweet quality **porno?** Well my friend, you're in luck. Keep jerking off, you disgusting animal!") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def tporn(ctx): """Sends porn pictures of trans people""" subreddit = await reddit.subreddit("ShemalesParadise") image_urls = [] async for submission in subreddit.hot(limit=200): if submission.url.endswith(('jpg', 'jpeg', 'png')): image_urls.append(submission.url) if not image_urls: return await ctx.send('No images found in the subreddit.') async def fetch_image(session, url): async with session.get(url) as resp: if resp.status != 200: return None return await resp.read() async with ctx.typing(): async with aiohttp.ClientSession() as session: tasks = [fetch_image(session, url) for url in image_urls] image_data = await asyncio.gather(*tasks) image_data = [data for data in image_data if data] if not image_data: return await ctx.send('Failed to download any images.') data = random.choice(image_data) embed = nextcord.Embed(title="Porn image - taken from **r/ShemalesParadise**", description="Are you horny? Looking for that sweet sweet quality **porno?** Well my friend, you're in luck. Keep jerking off, you disgusting animal!") embed.set_image(url="attachment://image.jpg") author_avatar_url = ctx.author.avatar.url if ctx.author.avatar else nextcord.Embed.Empty embed.set_author(name=f"Requested by: {ctx.author.name}", icon_url=author_avatar_url) channel = nextcord.utils.get(ctx.guild.channels, name="nsfw") if channel: file = nextcord.File(io.BytesIO(data), filename="image.jpg") await channel.send(embed=embed, file=file) else: await ctx.send("Couldn't find the channel 'nsfw'. Please create it.") @bot.command() async def meme(ctx): """Generates a random meme""" try: req = urllib.request.Request('https://meme-api.com/gimme', headers={'User-Agent': 'Mozilla/5.0'}) memeApi = urllib.request.urlopen(req) memeData = json.load(memeApi) memeUrl = memeData['url'] memeName = memeData['title'] memePoster = memeData['author'] embed = nextcord.Embed(title=memeName) embed.set_image(url=memeUrl) embed.set_author(name=f"Meme by: {memePoster}") await ctx.send(embed=embed) except Exception as e: await ctx.send(f"An error occurred: {e}") @bot.command() async def addtext(ctx, *, text: str): """Adds a text of choice over an image""" if len(ctx.message.attachments) == 0: await ctx.send("Please attach a file to your message.") return attachment = ctx.message.attachments[0] try: file_bytes = await attachment.read() except nextcord.HTTPException: await ctx.send("Failed to download the file.") return file_stream = io.BytesIO(file_bytes) try: image = Image.open(file_stream) except OSError: await ctx.send("Failed to open the file.") return draw = ImageDraw.Draw(image) font_size = 150 font_path = "/home/container/SteauaIntunecata/arial.ttf" font = ImageFont.truetype(font_path, int(font_size)) text_width = draw.textlength(text, font=font) num_lines = text.count('n') + 1 text_height = font_size * num_lines text_x = (image.width - text_width) // 2 text_y = (image.height - text_height) // 2 outline_color = (0, 0, 0) outline_thickness = 2 outline_position = [(text_x - outline_thickness, text_y - outline_thickness), (text_x + outline_thickness, text_y - outline_thickness), (text_x + outline_thickness, text_y + outline_thickness), (text_x - outline_thickness, text_y + outline_thickness)] draw.text((text_x - outline_thickness, text_y - outline_thickness), text, fill=outline_color, font=font) draw.text((text_x + outline_thickness, text_y - outline_thickness), text, fill=outline_color, font=font) draw.text((text_x - outline_thickness, text_y + outline_thickness), text, fill=outline_color, font=font) draw.text((text_x + outline_thickness, text_y + outline_thickness), text, fill=outline_color, font=font) draw.text((text_x, text_y), text, fill=(255, 255, 255), font=font) modified_image_bytes = io.BytesIO() image.save(modified_image_bytes, format='PNG') modified_image_bytes.seek(0) await ctx.send(file=nextcord.File(modified_image_bytes, filename='modified_image.png')) class InviteButtons(nextcord.ui.View): def __init__(self, inv: str): super().__init__() self.inv = inv self.add_item(nextcord.ui.Button(label="Invite Link", url=self.inv)) @nextcord.ui.button(label="Invite Btn", style=nextcord.ButtonStyle.blurple) async def inviteBtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): await interaction.response.send_message(self.inv) @bot.command() async def invite(ctx: commands.Context): """Creates an invite link for the server""" inv = await ctx.channel.create_invite() await ctx.send("Click the buttons below to create an invite link!", view=InviteButtons(str(inv))) async def create_balance(user): async with bot.db.cursor() as cursor: await cursor.execute("INSERT INTO bank VALUES(?, ?, ?, ?)", (0, 100, 500, user.id)) await bot.db.commit() return async def get_balance(user): async with bot.db.cursor() as cursor: await cursor.execute("SELECT wallet, bank, maxbank FROM bank WHERE user = ?", (user.id,)) data = await cursor.fetchone() if data is None: await create_balance(user) return 0, 100, 500 wallet, bank, maxbank = data[0], data[1], data[2] return wallet, bank, maxbank async def update_wallet(user, amount: int): async with bot.db.cursor() as cursor: await cursor.execute("SELECT wallet FROM bank WHERE user = ?", (user.id,)) data = await cursor.fetchone() if data is None: await create_balance(user) return 0 await cursor.execute("UPDATE bank SET wallet = ? WHERE user = ?", (data[0] + amount, user.id)) await bot.db.commit() @bot.command() async def balance(ctx: commands.Context, member: nextcord.Member = None): """Check how many drakes you have in your account""" if not member: member = ctx.author wallet, bank, maxbank = await get_balance(member) em = nextcord.Embed(title=f"{member.name}'s Balance") em.add_field(name="Wallet", value=wallet) em.add_field(name="Bank", value=f"{bank}/{maxbank}") await ctx.send(embed=em) async def update_bank(user, amount): async with bot.db.cursor() as cursor: await cursor.execute("SELECT wallet, bank, maxbank FROM bank WHERE user = ?", (user.id,)) data = await cursor.fetchone() if data is None: await create_balance(user) return 0 capacity = int(data[2] - data[1]) if amount > capacity: await update_wallet(user, amount) return 1 await cursor.execute("UPDATE bank SET bank = ? WHERE user = ?", (data[1] + amount, user.id)) await bot.db.commit() @bot.command() @commands.cooldown(1, 30, commands.BucketType.user) async def beg(ctx: commands.Context): """Can be used to beg for drakes""" chances = random.randint(1, 4) if chances == 1: await ctx.send("Unlucky, you got nothing.") else: amount = random.randint(5, 300) res = await update_wallet(ctx.author, amount) if res == 0: await ctx.send("No account found so one has just been created for you. Please run the command again using **s!beg**!") else: await ctx.send(f"You got **{amount}** drakes.") @beg.error async def beg_error(ctx, error): if isinstance(error, commands.CommandOnCooldown): remaining_time = error.retry_after minutes, seconds = divmod(remaining_time, 60) await ctx.send(f"Sorry, you need to wait **{int(seconds)}** seconds before using this command again.") @bot.command() @commands.cooldown(1, 5, commands.BucketType.user) async def withdraw(ctx: commands.Context, amount): """Used to withdraw your drakes""" wallet, bank, maxbank = await get_balance(ctx.author) try: amount = int(amount) except ValueError: pass if type(amount) == str: if amount.lower() == "max" or amount.lower() == "all": amount = int(wallet) else: amount = int(amount) bank_res = await update_bank(ctx.author, -amount) wallet_res = await update_wallet(ctx.author, amount) if bank_res == 0 or wallet_res == 0: return await ctx.send("No account found so one has been created for you. Please run the command again using **s!withdraw**!") elif bank_res == 1: return await ctx.send("You don't have enough storage in your bank!") wallet, bank, maxbank = await get_balance(ctx.author) em = nextcord.Embed(title=f"{amount} drakes have been withdrew from the bank.") em.add_field(name="New Wallet", value=wallet) em.add_field(name="New Bank", value=f"{bank}/{maxbank}") await ctx.send(embed=em) @bot.command() @commands.cooldown(1, 5, commands.BucketType.user) async def deposit(ctx: commands.Context, amount): """Used to deposit your drakes""" wallet, bank, maxbank = await get_balance(ctx.author) try: amount = int(amount) except ValueError: pass if type(amount) == str: if amount.lower() == "max" or amount.lower() == "all": amount = int(wallet) else: amount = int(amount) bank_res = await update_bank(ctx.author, amount) wallet_res = await update_wallet(ctx.author, -amount) if bank_res == 0 or wallet_res == 0: return await ctx.send("No account found so one has been created for you. Please run the command again using **s!deposit**!") elif bank_res == 1: return await ctx.send("You don't have enough storage in your bank!") wallet, bank, maxbank = await get_balance(ctx.author) em = nextcord.Embed(title=f"{amount} drakes have been deposited into your bank account.") em.add_field(name="New Wallet", value=wallet) em.add_field(name="New Bank", value=f"{bank}/{maxbank}") await ctx.send(embed=em) @bot.command() @commands.cooldown(1, 10, commands.BucketType.user) async def give(ctx: commands.Context, member: nextcord.Member, amount): """Used to give someone drakes""" wallet, bank, maxbank = await get_balance(ctx.author) try: amount = int(amount) except ValueError: pass if type(amount) == str: if amount.lower() == "max" or amount.lower() == "all": amount = int(wallet) else: amount = int(amount) wallet_res = await update_wallet(ctx.author, -amount) wallet_res2 = await update_wallet(member, amount) if wallet_res == 0 or wallet_res2 == 0: return await ctx.send("No account found so one has been created for you. Please run the commmand again using **s!give**!") wallet2, bank2, maxbank2 = await get_balance(member) em = nextcord.Embed(title=f"Gave {amount} drakes to {member.name}!") em.add_field(name=f"{ctx.author.name}'s Wallet", value=wallet) em.add_field(name=f"{member.name}'s wallet", value=wallet2) await ctx.send(embed=em) @bot.command() async def question(ctx): """Generate a random question for everyone to guess (mods only)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return global current_question, current_answer, questionactive if questionactive == True: await ctx.send("There is already an active question. Please wait for it to be answered.") return current_question, current_answer = random.choice(questions) questionactive = True general_channel = nextcord.utils.get(ctx.guild.channels, name='general') await general_channel.send(f"**Question:** {current_question}nPlease use **s!answer <ANSWER>** to answer the question!") @bot.command() async def answer(ctx, *, response): """Answer a question""" global questionactive if not questionactive: await ctx.send("There isn't an active question right now. Try again later!") return cleaned_response = response.strip().lower() cleaned_correct_answer = current_answer.strip().lower() if cleaned_response == cleaned_correct_answer: amount = random.randint(50, 200) await ctx.send(f"Correct! {ctx.author.mention} gets {amount} drakes.") questionactive = False await update_wallet(ctx.author, amount) else: await ctx.send(f"Wrong answer, {ctx.author.mention}.") @bot.command() async def time(ctx, city): """Shows the current time of the specified city""" try: tz = pytz.timezone(f"Europe/{city}") city_time = datetime.now(tz=tz) await ctx.send(f"The current date and time in **{city}** is **{city_time.strftime('%Y-%m-%d | %H:%M:%S')}**") except pytz.UnknownTimeZoneError: await ctx.send("Unknown time zone. Please provide a valid city.") @bot.command() async def syntax(ctx): """Shows the syntax of all the commands""" em = nextcord.Embed(title="Syntax of all the available commands") em.add_field(name="Commands", value="s!addtext <text> (have to send pic in order to add the text over it)ns!answer <answer>ns!av <user>ns!balancens!banner <user>ns!begns!deposit <amount>ns!give <user> <amount>ns!help (description of all the commands)ns!instapic <profile>ns!invitens!memens!mute <member> <time> <reason>ns!unmute <member> <reason>ns!play <youtube url>ns!pausens!resumens!stopns!questionns!rng <first number> <second number>ns!stealemoji <emoji link> <emoji name>ns!weather <city>ns!time <city>ns!withdraw <amount>ns!suggestion <suggestion>ns!approve <suggestion id> <reason>ns!deny <suggestion id> <reason>ns!membersns!qinfo <member>ns!sopns!pornns!mpornns!msopns!tsopns!tporn") em.add_field(name="Important", value="Commands without any syntax have only their name and nothing after them. Example: SYNTAX command = s!answer <answer> | NOT syntax = s!beg") await ctx.send(embed=em) @bot.command() async def suggestion(ctx, *, suggestion): """Adds a suggestion""" await ctx.channel.purge(limit=1) channel = nextcord.utils.get(ctx.guild.text_channels, name='suggestions-server-planning') suggest = nextcord.Embed(title="New suggestion!", description=f"{ctx.author.name} has suggested: **{suggestion}**") sugg = await channel.send(embed=suggest) await channel.send(f"Suggestion ID: **{sugg.id}**") await sugg.add_reaction('✅') await sugg.add_reaction('❌') async with bot.db.cursor() as cursor: await cursor.execute("INSERT INTO suggestions (author_id, suggestion_text, status) VALUES (?, ?, 'pending')", (ctx.author.id, suggestion)) await bot.db.commit() @bot.command() async def approve(ctx, id:int=None, *, reason=None): """Approves a suggestion (only for mods)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return if id is None: return if id in answered_suggestions: await ctx.send("This suggestion has already been answered.") return channel = nextcord.utils.get(ctx.guild.text_channels, name='suggestions-server-planning') if channel is None: return suggestionMsg = await channel.fetch_message(id) embed = nextcord.Embed( title="Suggestion approved!", description=f"The suggestion with the ID of **{suggestionMsg.id}** has been approved by **{ctx.author.name}** | Reason: **{reason}**", color=nextcord.Color.green() ) await channel.send(embed=embed) async with bot.db.cursor() as cursor: await cursor.execute("UPDATE suggestions SET status = 'approved' WHERE id = ?", (id,)) await bot.db.commit() answered_suggestions.append(id) @bot.command() async def deny(ctx, id:int=None, *, reason=None): """Denies a suggestion (only for mods)""" manager_role = nextcord.utils.get(ctx.guild.roles, name="manager") if manager_role is None or (manager_role not in ctx.author.roles and not ctx.author.guild_permissions.administrator): await ctx.send("You do not have permission to use this command.") return if id is None: return if id in answered_suggestions: await ctx.send("This suggestion has already been answered.") return channel = nextcord.utils.get(ctx.guild.text_channels, name='general') if channel is None: return suggestionMsg = await channel.fetch_message(id) embed = nextcord.Embed( title="Suggestion denied!", description=f"The suggestion with the ID of **{suggestionMsg.id}** has been denied by **{ctx.author.name}** | Reason: **{reason}**", color=nextcord.Color.red() ) await channel.send(embed=embed) async with bot.db.cursor() as cursor: await cursor.execute("UPDATE suggestions SET status = 'denied' WHERE id = ?", (id,)) await bot.db.commit() answered_suggestions.append(id) @bot.command() async def qinfo(ctx, member: nextcord.Member): """Shows informations of a member""" info_embed = nextcord.Embed(title=f"{member.name}'s quick account information", description="Some informations about the discord user.", color=member.color) info_embed.add_field(name="Name:", value=member.name, inline=False) info_embed.add_field(name="ID", value=member.id, inline=False) info_embed.add_field(name="Activity/Custom Status:", value=member.activity, inline=False) info_embed.add_field(name="Created at:", value=member.created_at.__format__('%A, %d %B %Y @ %H:%M:%S')) info_embed.set_thumbnail(url=member.avatar) await ctx.send(embed=info_embed) #@bot.command() #async def search(ctx, *, query): # # Pixabay API endpoint # url = f"https://pixabay.com/api/?key={APIPIXABAY_KEY}&q={query}&per_page=5" # # # Make the API request # response = requests.get(url) # # # Check if request was successful # if response.status_code == 200: # # Parse JSON response # data = response.json() # # # Send the image URLs # for hit in data['hits']: # await ctx.send(hit['largeImageURL']) # else: # await ctx.send("Error: Unable to retrieve image URLs.") #@bot.command() #async def gpt(ctx: commands.Context, *, prompt: str): # async with aiohttp.ClientSession() as session: # payload = { # "model": "gpt-3.5-turbo", # Update model name to a supported model # "prompt": prompt, # "temperature": 0.5, # "max_tokens": 50, # "presence_penalty": 0, # "frequency_penalty": 0, # "best_of": 1, # } # headers = {"Authorization": f"Bearer {CGAPI}"} # async with session.post("https://api.openai.com/v1/completions", json=payload, headers=headers) as resp: # response = await resp.json() # print("Response from AI:", response) # Print the response for debugging # if "choices" in response and len(response["choices"]) > 0 and "text" in response["choices"][0]: # response_text = response["choices"][0]["text"] # embed = nextcord.Embed(title="Chat GPT's Response:", description=response_text) # await ctx.reply(embed=embed) # else: # await ctx.reply(f'Failed to get a response from OpenAI.') bot.run(TOKEN)