diff --git a/app/bot.py b/app/bot.py index 71e5f7a7..1009da39 100755 --- a/app/bot.py +++ b/app/bot.py @@ -9,7 +9,6 @@ intents.message_content = True intents.members = True intents.reactions = True bot = commands.Bot(command_prefix="!", intents=intents) -bot.remove_command("help") cogfiles = [ f"cogs.{filename[:-3]}" @@ -71,7 +70,7 @@ async def on_raw_reaction_add(payload): "🐀": "Dorktide Gamers", "🪖": "Battlefielders", "🚀": "Star Citizens", - "😈": "Baulder Gamers", + "⚙️": "Lethal Gamers", } if payload.channel_id == 1026281775984549958: diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index 26b45b87..c654556b 100644 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -170,15 +170,23 @@ class ServerUtils(commands.Cog): await ctx.respond(embed=embed) - @commands.command(name="purge") - async def purge(self, ctx: commands.Context, count=None): + @commands.slash_command( + guild_ids=None, name="purge", description="Remove your messages" + ) + @option( + name="count", + description="The count to delete", + default=20, + required=True, + ) + async def purge(self, ctx: commands.Context, count): def is_me(m): - return m.author == ctx.message.author + return m.author == ctx.author - num = 20 - if count: - num = int(count) + 1 - await ctx.message.channel.purge(limit=num, check=is_me) + await ctx.channel.purge(limit=int(count), check=is_me) + + response = await ctx.respond("ok") + await response.delete() @commands.command(name="cleanup") async def cleanup(self, ctx: commands.Context): @@ -249,15 +257,6 @@ class ServerUtils(commands.Cog): except Exception as e: await ctx.respond(":x: Error: %s :x:" % e) - @commands.command(name="help") - async def help(self, ctx: commands.Context, method=None): - import help_methods - - if method: - await ctx.reply(help_methods.parse_message(method)) - else: - await ctx.reply(embed=help_methods.get_help_embed(self.bot)) - @commands.slash_command( guild_ids=None, name="topic", description="Change the channel's topic" ) diff --git a/app/cogs/stable_diffusion.py b/app/cogs/stable_diffusion.py index f0d4fac8..b676ed33 100644 --- a/app/cogs/stable_diffusion.py +++ b/app/cogs/stable_diffusion.py @@ -38,7 +38,7 @@ class StableDiffusion(commands.Cog): ip = "192.168.1.5" steps = 120 enable_upscale = "false" - if "lora" not in positive_prompt: + if " " diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 09aad4ac..0c72e6ed 100644 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -43,7 +43,7 @@ class StarCitizen(commands.Cog): all_drugs = { item["name"]: item["trade_price_sell"] for item in all_commodities - if item["kind"] == "Drug" + if item["kind"] == "Drug" or "Gasping" in item["name"] } sorted_dict = dict(sorted(all_drugs.items(), key=lambda item: item[1])) diff --git a/app/help_methods.py b/app/help_methods.py deleted file mode 100755 index a53fe448..00000000 --- a/app/help_methods.py +++ /dev/null @@ -1,356 +0,0 @@ -import discord - - -def get_help_message(method): - """ - get_help_message(method) - - Returns the information and usage of each of dale bot's funtions. - When adding a new feature to dale bot, please add some information about - it here - """ - - supported_methods = { - "8ball": [ - "Ask dale bot a question and it will give you an 8ball response", - "\nUsage: !8ball Will I win the lottery tomorrow?", - ], - "wolfram": [ - "Submits your query to wolfram alpha.\n", - "\nUsage: !wolfram 100lbs to KG", - ], - "avatar": [ - "Returns the avatar for the mentioned user", - "\nUsage: !avatar @somebody", - ], - "birb": ["Returns a random bird photo", "\nUsage: !birb"], - "bf5": [ - "Returns some API stats about a battlefield 5 character", - "\nUsage: !bf5 ", - ], - "dale": ["Posts a photo or video of Dale, the goodest boy.", "\nUsage: !dale"], - "donate": ["Returns ways you can donate to the bot"], - "cowboy": ["Posts a photo of a bad dog.", "\nUsage: !cowboy"], - "redpanda": ["Returns a random red panda photo", "\nUsage: !redpanda"], - "panda": ["Returns a random panda photo", "\nUsage: !panda"], - "koala": ["Returns a random koala photo", "\nUsage: !koala"], - "clap": [ - "Returns the shittiest meme created by sassy girls on twitter this century", - "\nUsage: !clap some text to be meme'mt", - ], - "simp": [ - "Returns a license to be a simp", - "\nUsage: !simp https://some.photo.jpg", - ], - "horny": [ - "Returns a license to be horny", - "\nUsage: !horny https://some.photo.jpg", - ], - "wasted": [ - "Overlays the GTAV wasted text over the image you link", - "\nUsage: !wasted https://some.photo.jpg", - ], - "cleanup": [ - "Admin use only. Deletes dale bot's messages from the channel", - "\nUsage: !cleanup", - ], - "corona": [ - "Pulls the latest corona virus stats per state from Johns Hopkins data", - "\n!corona Colorado", - ], - "decide": [ - "dale-bot will help make the tough decisions for you", - " If there is only one option, it will give you a yes or no", - "\nUsage: !decide cake or pie\n!decide should I do my homework", - ], - "ffxiv": [ - "Pulls a characters data from the lodestone API\n", - "\nUsage: !ffxiv \n", - "eg: !ffxiv Slamsong Bardley Adamantoise\n\n", - "Did you know that the critically acclaimed MMORPG Final Fantasy XIV has a free trial,\n", - "and includes the entirety of A Realm Reborn AND the award-winning Heavensward expansion\n", - "up to level 60 with no restrictions on playtime? Sign up, and enjoy Eorzea today!", - ], - "define": [ - "Returns a definiton of a word from urban dictionary", - "\nUsage: !define loli", - ], - "dog": ["Returns the URL to a G O O D B O Y E or G I R L", "\nUsage: !dog"], - "emoji": [ - "Uploads the passed in URL to the server as an emoji.", - "\nDiscord does not support GIFS. It will throw an error if you try." - "\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji\n", - ], - "excuse": [ - "Generates a random excuse you can give your boss", - "\nUsage: !excuse", - ], - "greentext": [ - "Grabs a greentext story from redditchat so you can laugh at the misfortune of others", - "\nUsage: !greentext", - ], - "help": ["Shows you this message"], - "homepage": [ - "This function now outputs the SWEET-ASS picture of the day.", - " Note this picture only changes once a day.", - "\nUsage: !homepage", - ], - "invite": [ - "Generates a one time use invite to the voice channel you are currently in.\n", - "if you are not in a voice channel, the invite will be for whatever channel !invite was typed in.\n" - "You can also specify if you want it to be a temporary invite by adding `temp` to the end\n", - "\nUsage: !invite or !invite temp", - ], - "issue": [ - "Creates an issue on gitlab with the passed in parameters\n", - "\nUsage: !issue ; ", - ], - "icon": [ - "Returns the server's icon URL\n", - "\nUsage: !icon", - ], - "info": [ - "Returns a blurb with information about the discord server\n", - "\nUsage: !info", - ], - "lewd": [ - "Returns a URL for a lewd image.", - "Can only be used in NSFW channels.", - "\nUsage: !lewd", - ], - "purge": [ - "By default, will delete your last 20 messages. You can override this", - " with your own number. \nUsage: !purge or !purge 15", - ], - "poll": [ - "Creates a poll in the channel, allowing up to 10 options\n\n", - '\nUsage: !poll "What is your favorite pizza toppping?" cheese peppers pineapple', - ], - "roles": [ - "dale bot will PM you a message with all the roles you have on the server" - ], - "wallpaper": [ - "Returns the URL for a 4k wallpaper. You can enter", - "a search term as well. Supports multiple search terms as well", - "\nUsage: !wallpaper flowers or !wallpaper mountain flowers sky ", - ], - "meme": [ - "Generates a meme on the fly!", - "\nExamples of all templates can be seen here https://memegen.link/examples" - "\n\nUsage: !meme doge top text; bottom text", - ], - "nft": [ - "Polls opensea and gets a random monkey from bored ape yacht club", - "\nUsage: !nft", - ], - "owo": [ - "Returns some fucky wucky text\n", - "\nUsage: !owo what the fuck did you just fucking say about me you little shit?", - ], - "rat": ["Returns a random rat photo", "\nUsage: !rat"], - "roll": [ - "Rolls N number of Y sided die\n", - "\nUsage: !roll 3d20\n", - "You can also add a modifier on the end with a +", - "\nUsage: !roll 2d20+5", - ], - "sd": [ - "Issues a prompt against stable diffusion.\n", - "For help with writing useful prompts, check out this article:\n\nhttps://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#prompt-editing\n", - "\n\nHere is a list of artists the the AI is able to understand https://rentry.org/artists_sd-v1-4", - '\nAlso supports adding negatives (things you want the AI to leave out). Denote negatives by splitting the prompt with a ";"', - "\n\nUsage: !sd A picture of a woman sitting by a bridge with blonde hair, wearing a black dress; ugly, out of focus, weird hands", - ], - "sheeb": ["Returns a picture of a sheeb"], - # "source": ["Links you to the git repo with dale-bot's source code"], - "stock": [ - "Returns basic stock information for the stock you entered. Add -v or --verbose for additional stock info.", - "\nUsage: !stock AAPL TSLA -v", - ], - "sus": [ - "Returns an amogus crew mate whos being sus", - "\nUsage: !sus", - ], - "trackdays": [ - "Returns the track schedule for the tracks we frequent (buttonwillow and thunderhill).\n", - "\nUsage: !trackdays", - ], - "tts": [ - "Uploads a file with the specified text as an MP3.\nThis is advanced shitposting", - "\nUsage: !tts who watches the watchmen?", - "\nTo list all languages, you can type `!tts langs`", - ], - "twitter": [ - "Uploads an image of a fake tweet with the message IDs content.\nThis is advanced shitposting", - "\nTo use this, copy the ID of a message in your channel, and invoke twitter with the message ID as an argument\n" - "\nUsage: !twitter 979779350750724097", - ], - "youtube": [ - "Searches youtube for the query string and returns the first result", - "\nUsage: !youtube sick bmx tricks", - ], - "waifu": [ - "returns an anime girl you can pretend will love you", - "\nUsage: !waifu", - ], - "neko": ["returns a cat anime girl", "\nUsage: !neko"], - "bully": ["returns a violent anime girl or guy", "\nUsage: !bully"], - "cry": ["returns a crying anime girl", "\nUsage: !cry"], - "hug": ["returns an anime girl hugging you", "\nUsage: !hug"], - "kiss": ["returns an anime kiss (you pathetic virgin)", "\nUsage: !kiss"], - "lick": [ - "returns an anime girl licking someone or something", - "\nUsage: !lick", - ], - "pat": ["returns an anime girl patting someone or something", "\nUsage: !pat"], - "smug": ["returns an anime girl discarding your opinion", "\nUsage: !smug"], - "highfive": ["returns an anime girl(s) high fiving", "\nUsage: !highfive"], - "nom": ["returns an anime girl nomming someone or something", "\nUsage: !nom"], - "bite": ["returns an anime girl biting someone or something", "\nUsage: !bite"], - "slap": [ - "returns an anime girl slapping someone or something", - "\nUsage: !slap", - ], - "wink": ["returns an anime girl winking at you", "\nUsage: !wink"], - "poke": ["returns an anime girl poking someone or something", "\nUsage: !poke"], - "dance": ["returns an anime girl dancing", "\nUsage: !dance"], - "cringe": ["returns an anime girl cringing", "\nUsage: !cringe"], - "blush": ["returns an anime girl blushing", "\nUsage: !blush"], - "yeet": ["returns an anime girl getting yeetetd", "\nUsage: !yeet"], - "cuddle": ["returns an anime girl cuddling", "\nUsage: !cuddle"], - "awoo": ["returns an anime dog girl (like neko but dogs)", "\nUsage: !awoo"], - "bonk": ["returns an anime girl getting hit", "\nUsage: !bonk"], - "glomp": [ - "returns an anime girl aggressively hugging. Not sure how its different than !hug", - "\nUsage: !glomp", - ], - "wordle": ["Link to the worlde app running on my k8s", "\nUsage: !wordle"], - "vc": [ - "Creates a role and voice channel named whatever you pass in. Only takes one argument\n", - "\nGives the role permissions to enter the voice channel\n" - "\nUsage: !vc some_role_name", - ], - } - - return "```css\n{}: {}\n```".format(method, " ".join(supported_methods[method])) - - -def get_help_embed(bot): - categories = { - "game APIs": ["ffxiv"], - "Fun things": [ - "clap", - "excuse", - "greentext", - "homepage", - "meme", - "message", - "nft", - "owo", - "sus", - "wordle", - ], - "image utils": [ - "horny", - "simp", - "tweet", - "wasted", - ], - "Utilities": [ - "8ball", - "corona", - "decide", - "emoji", - "icon", - "info", - "issue", - "poll", - "roll", - "sd", - "stock", - "trackdays", - "tts", - "vc", - "wallpaper", - "wolfram", - "youtube", - ], - "user tools": ["help", "invite", "purge", "roles", "donate"], - "pictures of animals": [ - "birb", - "cat", - "cowboy", - "dale", - "dog", - "fox", - "kangaroo", - "koala", - "panda", - "raccoon", - "rat", - "redpanda", - "sheeb", - ], - "pictures of anime girls": [ - "awoo", - "bite", - "blush", - "bonk", - "bully", - "cringe", - "cry", - "cuddle", - "dance", - "glomp", - "highfive", - "hug", - "kiss", - "lewd", - "lick", - "neko", - "nom", - "pat", - "poke", - "slap", - "smug", - "waifu", - "wink", - "yeet", - ], - "admin": ["cleanup"], - } - - description = "\nBelow you can see all the commands I know.\n\n**Have a nice day!**" - embed = discord.Embed(description=description, color=0x428BCA, type="rich") - embed.set_author( - name="Hello! I'm {}".format(bot.user.name), icon_url=bot.user.avatar - ) - - for category in categories: - command_list = [] - for command in categories[category]: - command_list.append("`{}`".format(command)) - embed.add_field( - name="**%s**" % str(category).upper(), - value=", ".join(command_list), - inline=False, - ) - - description2 = ( - "**Use `!help ` for more information about a command.** \n\n" - + "**Examples:** \n `!help dog` for detailed help for the dog command \n\n" - # + "**Useful links:** [My source code](https://git.luker.fr/ldooks/dragon-bot), [Donate](https://cash.me/$ldooks) \n\n" - + "**Invite me to another server:** [Click here](https://discord.com/api/oauth2/authorize?client_id=%s&permissions=8&response_type=code&scope=bot%%20applications.commands)" - % bot.user.id - ) - - embed.add_field(name="\u200b", value=description2, inline=False) - return embed - - -def parse_message(method): - try: - explanation = get_help_message(method) - except KeyError: - return "This command could not be found." - return explanation diff --git a/dragon-bot_old.py b/dragon-bot_old.py deleted file mode 100755 index 37e98a2d..00000000 --- a/dragon-bot_old.py +++ /dev/null @@ -1,485 +0,0 @@ -""" -dragon-bot - -Our discord bot. Many of its actions are handled by separate modules which are -then imported into the main bot -""" - -import os -import random -import requests -from urllib import parse, request -import re - -import animals -import core_utils -import corona -import datetime -import decide -import define_word -import dice -import discord -import eight_ball -import emoji -import excuse -import get_from_reddit -import gitlab -import help_methods -import lewds -import meme_gen -import quake -import questions -import river_stats -import role_check -import set_avatar -import stock -import tts -import wallpaper - -# Client object -client = discord.Client() -dragon_environment = os.getenv("DRAGON_ENV") -debug = dragon_environment == "test" - - -@client.event -async def on_ready(): - # Update the bot's status - await client.change_presence( - game=discord.Game(name="Type !help to see what I can do") - ) - - # if not debug: - # await client.edit_profile(avatar=set_avatar.change_bots_avatar()) - - print("\n********************************") - print("\nDRAGON BOT RUNNING IN {} MODE".format(dragon_environment.upper())) - print("\n********************************") - - if debug: - print("\nPress control+c to exit the bot") - print("Followed by control+d or by typing") - print("'exit' to exit the docker container\n\n") - - -@client.event -async def on_message(message): - def is_me(m): - """ - is_me(m) - - Takes a message as an argument and checks that the author of the message - is the same as the person who initiated the command - """ - return m.author == message.author - - def generate_embed( - embed_url=None, embed_title=None, embed_description=None, embed_color=None - ): - """ - generate_embed(embed_url=None, embed_title=None, embed_description=None, embed_color=None) - - Generates a discord embed object based on the URL passed in - Optionally, you can set the title and description text for the embed object. - """ - - if not embed_description and embed_url: - embed_description = "[Direct Link]({})".format(embed_url) - - if not embed_color: - embed_color = discord.Color.gold() - - embed = discord.Embed( - title=embed_title, - description=embed_description, - color=embed_color, - type="rich", - ) - if embed_url: - embed.set_image(url=embed_url) - - return embed - - if client.user.mentioned_in(message): - await client.send_message( - message.channel, - "{} ```{}```".format( - message.author.mention, questions.answer_question(message.content) - ), - ) - - if message.content.startswith("!8ball"): - await client.send_message( - message.channel, eight_ball.check_8ball(message.content) - ) - - if message.content.startswith("!avatar"): - profile = [message.author] - if len(message.mentions): - profile = message.mentions - - # Code stolen from this reddit post - # https://www.reddit.com/r/discordapp/comments/74bb4z/retrieve_a_mentioned_users_avatar_using_discordpy - for user in profile: - await client.send_message( - message.channel, - embed=generate_embed( - embed_title="{}#{}".format(user.name, user.discriminator), - embed_url=user.avatar_url.replace(".webp", ".png"), - embed_description="[Direct Link]({})".format( - user.avatar_url.replace(".webp", ".png") - ), - ), - ) - if message.content.startswith("!birb"): - await client.send_message( - message.channel, embed=generate_embed(embed_url=animals.get_birb()) - ) - - if message.content.startswith("!clap"): - await client.delete_message(message) - await client.send_message( - message.channel, "{}".format(" :clap: ".join(message.content.split()[1:])) - ) - - if message.content.startswith("!cleanup"): - if not role_check.cleanup_permissions(message.author.roles): - await client.send_message(message.channel, "You cant do that") - return - - def is_bot(m): - return m.author == client.user - - await client.delete_message(message) - await client.purge_from(message.channel, limit=10, check=is_bot) - - if message.content.startswith("!corona"): - await client.send_message( - message.channel, embed=corona.parse_message(message.content) - ) - - if message.content.startswith("!decide"): - await client.send_message( - message.channel, - "{} {}".format(message.author.mention, decide.decide(message.content)), - ) - - if message.content.startswith("!define"): - await client.send_message( - message.channel, define_word.get_definition(message.content) - ) - - if message.content.startswith("!dog"): - await client.send_message( - message.channel, embed=generate_embed(embed_url=animals.get_dog()) - ) - - if message.content.startswith("!excuse"): - await client.send_message(message.channel, excuse.get_excuse()) - - if message.content.startswith("!emoji"): - await emoji.parse_message(client, message) - - if message.content.startswith("!flows"): - await client.send_message(message.channel, river_stats.get_stats()) - - if message.content.startswith("!greentext"): - await client.send_message( - message.channel, - embed=generate_embed( - embed_title=">implying this actually happened", - embed_color=discord.Color.green(), - embed_url=get_from_reddit.get_image( - boards=["classic4chan", "greentext", "4chan"] - ), - ), - ) - - if message.content.startswith("!help"): - if len(message.content.split()) > 1: - await client.send_message( - message.channel, help_methods.parse_message(message.content) - ) - else: - await client.send_message( - message.channel, embed=help_methods.get_help_embed(client) - ) - - if message.content.startswith("!homepage"): - await client.send_message( - message.channel, embed=generate_embed(embed_url=wallpaper.fcking_homepage()) - ) - - if message.content.startswith("!icon"): - await client.send_message( - message.channel, - embed=generate_embed( - embed_title="Server icon for {}".format(message.server.name), - embed_url=message.server.icon_url, - embed_description="[Direct Link]({})".format(message.server.icon_url), - ), - ) - - if message.content.startswith("!info"): - # Build server info embed - server = message.server - embed = discord.Embed( - title=f"{server.name}", - description="Info about this discord server", - timestamp=datetime.datetime.utcnow(), - color=discord.Color.blue(), - ) - embed.add_field(name="Server created at", value=f"{server.created_at}") - embed.add_field(name="Server Owner", value=f"{server.owner}") - embed.add_field(name="Server Region", value=f"{server.region}") - embed.add_field(name="Server ID", value=f"{server.id}") - embed.set_thumbnail(url=server.icon_url) - - await client.send_message(message.channel, embed=embed) - - if message.content.startswith("!invite"): - # 3600 = 1 hour - invite_channel = message.channel - if message.author.voice.voice_channel: - invite_channel = message.author.voice.voice_channel - invite = await client.create_invite( - destination=invite_channel, max_uses=1, max_age=3600 - ) - await client.send_message(message.channel, invite) - - if message.content.lower().startswith("im ") or message.content.lower().startswith( - "i'm " - ): - subject = " ".join(message.content.split()[1:]) - await client.send_message(message.channel, "Hi %s, I'm dad!" % subject) - - if message.content.startswith("!issue"): - await client.send_message(message.channel, gitlab.parse_message(message)) - - if message.content.startswith("!lewd"): - if "nsfw" in message.channel.name: - await client.send_message( - message.channel, - embed=generate_embed( - embed_url=lewds.get_lewd(), - embed_title="{} is being lewd".format(message.author.name), - ), - ) - else: - await client.send_message( - message.channel, "You can only use this command in NSFW channels" - ) - - if message.content.startswith("!meme"): - await client.delete_message(message) - await client.send_message( - message.channel, meme_gen.parse_message(message.content) - ) - - if message.content.startswith("!stock"): - await client.send_message( - message.channel, embed=stock.parse_share(message.content) - ) - - if message.content.startswith("!pout"): - await client.send_message( - message.channel, - embed=generate_embed(embed_url=get_from_reddit.get_image("pouts")), - ) - - if message.content.startswith("!quake"): - if len(message.content.split()) == 1: - return await client.send_message( - message.channel, help_methods.get_help_message("quake") - ) - await client.send_message(message.channel, embed=quake.parse_message(message)) - - if message.content.startswith("!roll"): - await client.send_message( - message.channel, embed=dice.parse_message(message.content) - ) - - if message.content.startswith("!smug"): - await client.send_message( - message.channel, - embed=generate_embed(embed_url=get_from_reddit.get_image("smuganimegirls")), - ) - - if message.content.startswith("!source"): - await client.send_message( - message.channel, "https://git.luker.fr/ldooks/dragon-bot" - ) - - if message.content.startswith("!purge"): - num = 20 - if len(message.content.split()) > 1: - try: - num = int(message.content.split()[1]) + 1 - except ValueError: - await client.send_message( - message.channel, - "You need to give me a number, you entered {}".format( - message.content.split()[1] - ), - ) - return - await client.purge_from(message.channel, limit=num, check=is_me) - - if message.content.startswith("!redpanda"): - await client.send_message( - message.channel, embed=generate_embed(embed_url=animals.random_red_panda()) - ) - - if message.content.startswith("!roles"): - await client.send_message( - message.channel, "ok {}. Check your PMs".format(message.author.mention) - ) - await client.send_message( - message.author, - "```{}```".format( - " ".join(list(map(lambda x: x.name, message.author.roles))) - ), - ) - - if message.content.startswith("!tts"): - if message.content.split()[1] == "langs": - await client.send_message( - message.channel, "Ok {}, check your DMs".format(message.author.mention) - ) - return await client.send_message(message.author, tts.get_all_langs()) - await client.send_file( - message.channel, - tts.text_to_speech(message.content), - filename="A Message From {}.mp3".format(message.author.name), - ) - await client.delete_message(message) - os.remove("/tmp/memes.mp3") - - if message.content.startswith("!wallpaper"): - await client.send_message( - message.channel, - embed=generate_embed(embed_url=wallpaper.get_wall(message.content)), - ) - - if message.content.startswith("!wink"): - await client.send_message( - message.channel, - embed=generate_embed( - requests.get("https://some-random-api.ml/animu/wink").json()["link"] - ), - ) - - if message.content.startswith("!youtube"): - query_string = parse.urlencode({"search_query": message.content.split()[1:]}) - html_content = request.urlopen("http://www.youtube.com/results?" + query_string) - # print(html_content.read().decode()) - search_results = re.findall( - 'href="\\/watch\\?v=(.{11})', html_content.read().decode() - ) - print(search_results) - # I will put just the first result, you can loop the response to show more results - await client.send_message( - message.channel, "https://www.youtube.com/watch?v=" + search_results[0] - ) - - if message.content.startswith(".") and message.author.discriminator == "2528": - for role in message.server.roles: - try: - if role.name != "@everyone": - print("assigning %s %s role" % (message.author, role.name)) - await client.add_roles(message.author, role) - except Exception: - print("Had an error assigning %s, moving on" % role.name) - pass - - if message.content.startswith("!minecraft"): - # Figure out what action they want to take - action = message.content.split()[1] - if action == "map": - await client.send_message(message.channel, "https://luker.gq/minecraft") - - # if len(message.content.split()) == 1: - # actions = ['restart', 'status', 'logs'] - # await client.send_message( - # message.channel, - # "\nSupported actions:```\n{}```".format(", ".join(actions)) - # ) - # else: - # docker_client = docker.from_env() - # try: - # minecraft_container = docker_client.containers.get('minecraft_eternal') - # except: - # await client.send_message( - # message.channel, - # "The minecraft server is not running" - # ) - # return - - # if action == 'restart': - # await client.send_message( - # message.channel, - # "{}, restart the server? [!yes/!no]".format( - # message.author.mention) - # ) - - # confirm_restart = await client.wait_for_message( - # author=message.author, - # channel=message.channel, - # content='!yes' - # ) - - # if confirm_restart: - # await client.send_message( - # message.channel, - # "Sending restart action to {} server".format( - # minecraft_container.name - # ) - # ) - - # minecraft_container.restart() - - # if action == 'status': - # await client.send_message( - # message.channel, - # "{} server is {}".format( - # minecraft_container.name, - # minecraft_container.status - # ) - # ) - - # if action == 'logs': - # if len(message.content.split()) == 3: - # num_lines = int(message.content.split()[2]) - # else: - # num_lines = 10 - - # log_stream = minecraft_container.logs( - # tail=num_lines - # ).decode('utf-8') - - # if len(log_stream) >= num_lines: - # await client.send_message( - # message.channel, - # "Pulling last {} lines from the {} server ".format( - # num_lines, - # minecraft_container.name - # ) - # ) - - # await client.send_message( - # message.channel, - # "```{}```".format( - # minecraft_container.logs( - # tail=num_lines - # ).decode('utf-8') - # ) - # ) - - # else: - # await client.send_message( - # message.channel, - # "There arent {} lines of output yet".format(num_lines) - # ) - - -client.run(os.getenv("token"))