# discord.py | Steam LFG Bot # ################ Imports ######################## import ast import json import traceback from collections import Counter import discord import discord.guild import discord.reaction import discord.user import discord.utils import requests import validators from discord import Embed, Activity, ActivityType, errors, utils, Intents, ChannelType from discord.ext import commands from dislash import InteractionClient, ActionRow, Button, ButtonStyle, SelectMenu, SelectOption, Option, OptionType, OptionChoice, SlashCommand, MessageInteraction, ContextMenuInteraction import mysql.connector import datetime from datetime import timedelta import random import os import re import steam from steam.steamid import SteamID from steam.webapi import WebAPI from aoe2netapi import API as AOE2_API import profanity_filter from profanity_filter import ProfanityFilter # ################ Globals ######################## client = commands.Bot(command_prefix='/', case_insensitive=True, intents=Intents.all()) slash = InteractionClient(client, sync_commands=True) apiauth = WebAPI(os.environ['API_AUTH']) aoe2_apiauth = AOE2_API() pfilter = ProfanityFilter() pfilter.censor_char = '•' # Important URLs url_discord = 'https://discord.gg/8DE5z5tTY8' url_website = 'https://valkyrinllc.gitbook.io/steamlfgservice/' url_redirect = 'https://lfg-redirect.herokuapp.com/redirect.php?url=' # Image URLs img_tip = 'https://cdn.discordapp.com/attachments/860960452074536982/860960473980862505/tip.png' img_logo = 'https://cdn.discordapp.com/attachments/860960452074536982/873043699423125534/LFGEvent_Logo_-_Gif_-_Without_Text_-_Upscale.gif' img_steam = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/512px-Steam_icon_logo.svg.png' img_error = 'https://cdn0.iconfinder.com/data/icons/shift-free/32/Error-512.png' img_unknown = 'https://media3.giphy.com/media/eTVG7eVNnud8Y/giphy.gif?cid=ecf05e47w0ufpij8y4o8u7kyco0f3y37xa84f00rzn72ps89&rid=giphy.gif&ct=g' # Embed Colors clr_error = 15158332 # Embed Text txt_footer = 'Running into issues or have a question?\nClick the message title to join our Support Discord!' txt_interact = '❕┃**Interaction Completed**' txt_tip = '**Technical Issues:** <:discord:902408218138005575> [**Support Server**](https://discord.gg/8DE5z5tTY8)\n**Learn More:** <:logo:908953639085821973> [**Read the Docs**](https://valkyrinllc.gitbook.io/steamlfgservice/)' txt_error = 'Sent' txt_long = 'Text longer than 1024 characters, please shorten response and try again. Consider using `/modify` to add your shortened response to your post.' # Support Buttons for encountered errors support_buttons = [ActionRow( Button(style=ButtonStyle.secondary, label="Ticket Status", emoji='📩', custom_id='faq_status'), Button(style=ButtonStyle.secondary, label="Submit Error Report", emoji='🛠️', custom_id='faq_report'), Button(style=ButtonStyle.secondary, label="Submit Suggestion", emoji='📝', custom_id='faq_suggest'), Button(style=ButtonStyle.link, label="Support Server", emoji='👥', url='https://discord.gg/8DE5z5tTY8') )] # Slash Options 🔔 for notify button sopt_setup_choose = SelectMenu( custom_id='setup_choose', options=[ SelectOption(label="Change Global LFG Network Preference", description='Choose to Opt-In or Out of our Global LFG Network!', value="setup_choose-lfg", emoji='👥'), SelectOption(label="Change LFG Channel & Game Restrictions", description='Choose how to Restrict LFG on your Discord Server!', value="setup_choose-restrict", emoji='🕹️'), SelectOption(label="Assign LFG Notification Channels", description='Associate channels to be messaged on LFG Requests for games!', value="setup_choose-channels", emoji='🔔'), SelectOption(label="Assign Role Pings for LFG Requests", description='Associate roles to be pinged on LFG Requests for games!', value="setup_choose-roles", emoji='💼'), SelectOption(label="Setup Auto-Delete Timer for LFG Requests", description='Designate a auto-removal time for LFG Requests!', value="setup_choose-remove", emoji='🗑️'), SelectOption(label="Control LFG Post Default Banner Images", description='Control whether to display a game\'s banner for LFG Posts!', value="setup_choose-banner", emoji='🖼️'), SelectOption(label="Control LFG Post Thread Automatic Creation", description='Control whether to auto-create threads for LFG Posts!', value="setup_choose-threads", emoji='📝'), SelectOption(label="Allow or Prohibit Multiple Active LFG Posts", description='Control users having more than one active LFG Post!', value="setup_choose-active", emoji='🔂'), SelectOption(label="Enable or Disable /host Usage", description='Control whether to allow usage of /host!', value="setup_choose-host", emoji='🎬') ], placeholder="Choose which setup option to choose from!", min_values=1, max_values=1, ) sopt_setup_lfg = SelectMenu( custom_id='global_lfg', options=[ SelectOption(label="Opt-In", description='Server LFG Posts & invite visible on LFG Network', value="global_lfg-in", emoji="✔️"), SelectOption(label="Opt-Out", description='Server LFG Posts & invite removed from LFG Network', value="global_lfg-out", emoji="❌"), SelectOption(label="Configure Internal Invites", description='Visibility of this Discord\'s invite on the LFG Network', value="global_lfg-invite", emoji="🔗") ], placeholder="Opt-In or Out of our Global LFG Network!", min_values=1, max_values=1, ) sopt_setup_invite = SelectMenu( custom_id='internal_invites', options=[ SelectOption(label="Visible", description='Show this Discord\'s invite on posts for the LFG Network', value="internal_invites-enable", emoji="✔️"), SelectOption(label="Hidden", description='Hide this Discord\'s invite on posts for the LFG Network', value="internal_invites-disable", emoji="❌") ], placeholder="Invite visibility on the Global LFG Network!", min_values=1, max_values=1, ) sopt_setup_restrict = SelectMenu( custom_id='lfg_restrict', options=[ SelectOption(label="Option 1", description='Only restrict `/host` usage to certain channel(s)', value="lfg_restrict-1", emoji='🛠️'), SelectOption(label="Option 2", description='Only restrict `/host` usage to certain game(s)', value="lfg_restrict-2", emoji='🛠️'), SelectOption(label="Option 3", description='Restrict `/host` to channel(s) AND game(s) together', value="lfg_restrict-3", emoji='🛠️'), SelectOption(label="Option 4", description='Allow `/host` in all channel(s) and for all game(s)', value="lfg_restrict-4", emoji='🛠️') ], placeholder="Restrict LFG on your Discord Server!", min_values=1, max_values=1, ) sopt_setup_channels = SelectMenu( custom_id='notify_channels', options=[ SelectOption(label="Setup Channel Notifications", description='Provide channels to show new LFG Posts on the Network', value="notify_channels-setup", emoji="🔔"), SelectOption(label="Disable Channel Notifications", description='No channels will show new LFG Posts on the Network', value="notify_channels-none", emoji="❌"), SelectOption(label="Configure Discord Links", description='Control whether to show join links to external Discords', value="notify_channels-invites", emoji="🔗") ], placeholder="Showcase new LFG Posts from the Network!", min_values=1, max_values=1, ) sopt_channels_invites = SelectMenu( custom_id='channels_choice', options=[ SelectOption(label="Allow Discord Links", description='Show join links to external Discords for LFG Posts from the Network', value="channels_choice-show", emoji="🔗"), SelectOption(label="Disallow Discord Links", description='Only show Join Game and Add Friend buttons for LFG Posts from the Network', value="channels_choice-none", emoji="❌") ], placeholder="Join Links on LFG Posts in channels setup!", min_values=1, max_values=1, ) sopt_setup_roles = SelectMenu( custom_id='post_roles', options=[ SelectOption(label="Setup Roles Pings on `/host` usage", description='Provide roles to be ping for games on `/host` usage', value="post_roles-setup", emoji="👥"), SelectOption(label="Do not Ping Roles on `/host` usage", description='No roles will be pinged after `/host` usage', value="post_roles-none", emoji="❌") ], placeholder="Choose if to ping roles on LFG Requests!", min_values=1, max_values=1, ) sopt_setup_remove = SelectMenu( custom_id='post_delete', options=[ SelectOption(label="Setup Auto-Delete Timers on `/host` usage", description='Provide time in minute to auto-delete posts from `/host` usage', value="post_delete-setup", emoji="⏲️"), SelectOption(label="Do not use Auto-Delete Timers on `/host` usage", description='Posts from `/host` usage will never auto-delete', value="post_delete-none", emoji="❌") ], placeholder="Choose if to auto-delete LFG Requests over time!", min_values=1, max_values=1, ) sopt_setup_banner = SelectMenu( custom_id='banner_setup', options=[ SelectOption(label="Disable Default Banners", description='Disable the default game\'s banner on new LFG Posts', value="banner_setup-disable", emoji="❌"), SelectOption(label="Enable Default Banners", description='Enable the default game\'s banner on new LFG Posts', value="banner_setup-enable", emoji="🖼️") ], placeholder="Display game\'s default banner for LFG Posts!", min_values=1, max_values=1, ) sopt_setup_thread = SelectMenu( custom_id='thread_setup', options=[ SelectOption(label="Disable Thread Auto-Creation", description='Disable auto-creation of threads for each new LFG Post', value="thread_setup-disable", emoji="❌"), SelectOption(label="Enable Thread Auto-Creation", description='Enable auto-creation of threads for each new LFG Post', value="thread_setup-enable", emoji="📝") ], placeholder="Control auto-create threads for LFG Posts!", min_values=1, max_values=1, ) sopt_setup_active = SelectMenu( custom_id='active_setup', options=[ SelectOption(label="Restrict to One Active LFG Post", description='Replace a user\'s last LFG request with their new one', value="active_setup-disable", emoji="❌"), SelectOption(label="Allow Multiple Active LFG Posts", description='Allow users to have multiple LFG requests open at once', value="active_setup-enable", emoji="🔂") ], placeholder="Restrict active LFG Posts for users at once!", min_values=1, max_values=1, ) sopt_setup_host = SelectMenu( custom_id='host_setup', options=[ SelectOption(label="Disable /host Command Usage", description='Disables /host usage, best for if your prefer to only use /link', value="host_setup-disable", emoji="❌"), SelectOption(label="Enable /host Command Usage", description='Enables normal /host usage at anytime by any user', value="host_setup-enable", emoji="🎬") ], placeholder="Disable or enable /host usage by users!", min_values=1, max_values=1, ) sopt_notify_setup = SelectMenu( custom_id='notify_setup', options=[ SelectOption(label="Setup Notifications", description='Specify Notification settings for LFG Posts', value="notify_setup-modify", emoji="🔔"), SelectOption(label="Clear Notifications", description='Remove all Notifications for LFG Posts', value="notify_setup-clear", emoji="❌") ], placeholder="Clear or Modify Notifications for LFG Posts!", min_values=1, max_values=1, ) sopt_register = [ Option( name="friend_code", description="👥 Steam Friend Code - (Guide: https://www.howtogeek.com/671958/how-to-find-a-friend-code-in-steam/):", type=4, required=True)] sopt_karma = [ Option( name="user_id", description="👥 Discord Account ID of User to query Karma total of (Tip: You can use `@` to mention them instead):", type=3, required=False)] sopt_announce = [ Option( name="announcement", description="💬 Your message to broadcast (Tip: Use \\n for new lines):", type=3, required=True)] sopt_notify = [ Option( name="subscription", description="🔔 Format for User and Games you would like to subscribe to (Tip: For instructions ignore this):", type=3, required=False)] sopt_host = [ Option( name="description", description="💬 Brief overview of your plans (Tip: Include Lobby ID if not Host):", type=3, required=False), Option( name="rules", description="📜 Overview of restrictions players are expected to abide by upon joining Lobby or Server:", type=3, required=False), Option( name="password", description="🔑 Password of Lobby or Server to allow join (Generated Join link still require password):", type=3, required=False), Option( name="banner", description="🖼️ A link to an image or gif for your LFG Post's banner, otherwise it will be the Game Store banner:", type=3, required=False)] sopt_link = [ Option( name="password", description="🔑 Password of Server to allow join (Only provide IF Server is connected to via IP Address):", type=3, required=False)] sopt_modify = [ Option( name="post_id", description="💬 Provide a Message ID, numbers ONLY (Options or right-click the desired message, select `Copy Id`):", type=3, required=True), Option( name=sopt_host[0].name, description=sopt_host[0].description, type=3, required=False), Option( name=sopt_host[1].name, description=sopt_host[1].description, type=3, required=False), Option( name=sopt_host[2].name, description=sopt_host[2].description, type=3, required=False), Option( name=sopt_host[3].name, description=sopt_host[3].description, type=3, required=False)] sopt_search = [ Option( name="game_steam_url", description="🔗 Provide a game\'s Steam Store URL (Ex: https://store.steampowered.com/app/281990/Stellaris/):", type=3, required=True), Option( name="keywords", description="💬 Provide a phrase to search for in current LFG Posts descriptions and rules for your provided Game:", type=3, required=False), Option( name="rules", description="📜 Restrict your search to LFG Posts which have rules:", type=3, required=False, choices=[ OptionChoice( name="Rules Provided", value="search_parameters-rules") ]), Option( name="password", description="🔑 Restrict your search to LFG Posts which have passwords:", type=3, required=False, choices=[ OptionChoice( name="Password Required", value="search_parameters-password" )])] # Special Embed Messages msg_private = Embed(title='❌┃Slash Command Forbidden', description='We apologize however, please only use this particular Slash Command within a Discord Server\'s text channels, instead of Private Messaging it.\n\n**Note:** Only `/register`, `/notify`, `/search`, `/announce` and, `/karma` may be used here.', color=clr_error) msg_private.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_private.set_thumbnail(url=img_error) msg_private.timestamp = datetime.datetime.now() msg_private.set_footer(text=txt_error + str(msg_private.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_process = Embed(title='⏳┃Processing request', description='<@284839059157942274> is thinking...', color=0xffffff) # Global MySQl Connection database = mysql.connector.connect( host=os.environ['SQL_HOST'], port=3306, user=os.environ['SQL_USER'], password=os.environ['SQL_PASS'], database=os.environ['SQL_DB'] ) sql_connect = database.cursor(dictionary=True, buffered=True) # ################# MySQL Commit Database ################### @client.event async def mysql_commit(sql, val): global database global sql_connect # Refresh MySQl connection database = mysql.connector.connect( host=os.environ['SQL_HOST'], port=3306, user=os.environ['SQL_USER'], password=os.environ['SQL_PASS'], database=os.environ['SQL_DB'] ) sql_connect = database.cursor(dictionary=True, buffered=True) sql_connect.execute(sql, val) database.commit() # ################# MySQL Update Guilds ################### @client.event async def sql_update_guilds(): print('Updating Guilds Table: ' + str(datetime.datetime.now())) for guild in client.guilds: sql = "SELECT guild_id FROM guilds WHERE guild_id = %s" val = (guild.id,) sql_connect.execute(sql, val) sql_fetch = sql_connect.fetchone() if sql_fetch is None: print('New guild found: ' + str(guild.name)) sql = "INSERT INTO guilds (guild_id, guild_owner_id) VALUES (%s, %s)" val = (guild.id, guild.owner.id) await mysql_commit(sql=sql, val=val) # ################ On Ready ######################## @client.event async def on_ready(): print(f'{client.user.name} has connected to Discord: ' + str(datetime.datetime.now())) await client.change_presence(activity=Activity(type=ActivityType.listening, name='ℹ️ - `/setup` for help ')) await sql_update_guilds() # IMPLEMENT GLOBAL BLACKLIST GUILD ID CHECK BEFORE LAUNCH!!!!!! for guild in client.guilds: sql = "SELECT global_lfg_invite FROM guilds WHERE guild_id = %s AND global_lfg_opt = %s" val = (guild.id, 'In') await mysql_commit(sql=sql, val=val) invite = sql_connect.fetchall() if invite: try: await client.fetch_invite(invite[0]['global_lfg_invite']) except errors.NotFound: try: text_channel = random.choice(guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), guild.id) await mysql_commit(sql=sql, val=val) except: pass pass sql_connect.execute("SELECT guild_id FROM guilds") ids = sql_connect.fetchall() guild_ids = [] for idx, guild_id in enumerate(ids): guild_ids.append(ids[idx]['guild_id']) joined_guild_ids = [] for guild_client in client.guilds: if str(guild_client.id) in guild_ids: joined_guild_ids.append(str(guild_client.id)) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (guild_client.id,) await mysql_commit(sql=sql, val=val) guild_params = sql_connect.fetchall() if guild_params[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite(str(guild_params[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(guild_client.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), guild_client.id) await mysql_commit(sql=sql, val=val) except: pass pass for guild_id in guild_ids: if guild_id not in joined_guild_ids: sql = "UPDATE guilds SET guild_status = %s WHERE guild_id = %s AND global_lfg_opt = %s" val = ('Out', guild_id, 'In') await mysql_commit(sql=sql, val=val) sql_connect.execute("SELECT * FROM posts") posts_checked = sql_connect.fetchall() posts_remove = [] for post in posts_checked: try: channel = client.get_channel(int(post['channel_id'])) post = await channel.fetch_message(int(post['message_id'])) except: posts_remove.append(post['message_id']) continue if posts_remove: for post in posts_remove: sql = "SELECT * FROM posts WHERE message_id = %s" val = (post,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (post,) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (post,) await mysql_commit(sql=sql, val=val) updates_channel = client.get_channel(285530095005728778) # # post_buttons = [ActionRow( # Button(style=ButtonStyle.secondary, label="Ticket Status", emoji='📩', custom_id='faq_status'), # Button(style=ButtonStyle.secondary, label="Submit Error Report", emoji='🛠️', custom_id='faq_report'), # Button(style=ButtonStyle.secondary, label="Submit Suggestion", emoji='📝', custom_id='faq_suggest'), # Button(style=ButtonStyle.link, label="Rate Service", emoji='🌟', url='https://valkyrinllc.gitbook.io/steamlfgservice/') # )] # post_buttons = [ActionRow( # Button(style=ButtonStyle.link, label="Read the Docs", emoji='❔', url='https://valkyrinllc.gitbook.io/steamlfgservice/') # )] # # msg_faq = Embed(title='<:logo:908953639085821973>┃Steam LFG Service FAQ', description='This server serves as a support area for the `' + client.user.name + '` Discord bot.', color=0x738adb) # msg_faq.add_field(name='❔┃Available Options', value='We are always actively seeking out any error reports and suggestions for features you\'d like to see. Feel free to use the below buttons to open a bug or support ticket.', inline=False) # msg_faq.add_field(name='💬┃Contact Us', value='**Technical Issues:** <:discord:902408218138005575> <@224349699061186570>\n**Learn More:** <:logo:908953639085821973> [**Read the Docs**](https://valkyrinllc.gitbook.io/steamlfgservice/)', inline=False) # msg_faq.timestamp = datetime.datetime.now() # msg_faq.set_footer(text='Posted' + str(msg_faq.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # await guild.system_channel.send(embed=msg_faq, components=post_buttons) # # msg_updates = Embed(title='<:check:902430116234285136>┃Steam LFG Service Updates', description='This channel provides a changelog for the `' + client.user.name + '` Discord bot.', color=0x738adb) # msg_updates.add_field(name='❔┃Update Schedule', value='We strive to improve our service and add innovative features. We refresh our services and push updates on Sunday evenings to avoid impactful downtime.', inline=False) # msg_updates.add_field(name='💬┃Contact Us', value='**Technical Issues:** <:discord:902408218138005575> <@224349699061186570>\n**Learn More:** <:logo:908953639085821973> [**Read the Docs**](https://valkyrinllc.gitbook.io/steamlfgservice/)', inline=False) # msg_updates.timestamp = datetime.datetime.now() # msg_updates.set_footer(text='Posted' + str(msg_updates.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # await updates_channel.send(embed=msg_updates) # # msg_guide = Embed(title='<:logo:908953639085821973>┃Steam LFG Service FAQ', description='See below for usage of <@' + str(client.user.id) + '> developed by <@224349699061186570>.', color=0x738adb) # msg_guide.add_field(name='❔┃Purpose', value='Steam LFG Service is a LFG solution written in [**Python**](https://www.python.org/), based on the [**Steam API**](https://partner.steamgames.com/doc/webapi). We provide a easy to use and robust customizable Discord Bot, for any server looking to be a hub for Steam Gamers.\n\nThis project was created with a desire to help streamline the process for Discord Users attempting to connect via Steam. It makes great usage of the [**Steam Browser Protocol**](https://developer.valvesoftware.com/wiki/Steam_browser_protocol) allowing to automatically join users to lobbies and, friend hosts!\n\nTo begin organizing your next game visit <#285530095005728778> and type **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)**', inline=False) # msg_guide.add_field(name='📝┃Host Commands', value='• **[`/register`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/register)** - Associates a Steam Profile with your Discord Account.\n• **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** - Creates an LFG Post for your Steam game currently opened.\n• **[`/modify`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/modify)** - Adds or changes fields on an existing LFG post of yours.\n• **[`/link`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/link)** - Generates a Steam Join Lobby and Add Friend link for others to use.\n• **[`/announce`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/announce)** - Used to broadcast a message to users subscribed to you.', inline=False) # msg_guide.add_field(name='📑┃User Commands', value='• **[`/karma`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/karma)** - Provides a user\'s karma and standing, as well as to check leaderboards.\n• **[`/search`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/search)** - Browses a game\'s active LFG Posts on the Global LFG Network.\n• **[`/notify`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/notify)** - Alerts you of new LFG Posts from the Global LFG Network', inline=False) # msg_guide.add_field(name='📩┃Context Actions', value='• For ease-of-access you may also use a set of mini-commands simply by right clicking/hold pressing any message or user within a Discord server, then selecting an item from the **Apps** list.\n• These includes subscribing to a host, checking their karma, or fetching their lobby information, further info read our **[Wiki](https://valkyrinllc.gitbook.io/steamlfgservice/context-actions)**!', inline=False) # msg_guide.add_field(name='📣┃Provide Feedback', value='We are always actively seeking out any error reports and suggestions for features you\'d like to see. Feel free to use the below buttons to open a bug or support ticket.', inline=False) # msg_guide.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) # msg_guide.timestamp = datetime.datetime.now() # msg_guide.set_footer(text='Posted' + str(msg_guide.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # channel = client.get_channel(925245990087323648) # msg = await channel.fetch_message(925256051266318356) # await msg.edit(embed=msg_guide, components=post_buttons) # await updates_channel.send(embed=msg_guide, components=post_buttons) # # msg_guide = Embed(title='<:logo:908953639085821973>┃New Host Karma System', description='Please note the old system for giving host karma has been revamped, see below!', color=0x738adb) # msg_guide.add_field(name='❔┃Purpose', value='Karma distinguishes hosts, encourage competition and, provides them **thanks**! ', inline=False) # msg_guide.add_field(name='🙏┃Give Karma', value='\n• A host may run **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** to generate a LFG Post in <#285530095005728778>.\n• Press the attached **[`👍🏼`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/karma)** button on the host\'s LFG post to give them **+1 Karma**.', inline=False) # msg_guide.add_field(name='📧┃Check Karma', value='• **[`/karma`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/karma)** - Provides server and global top 10 leaderboards for host karma.\n• **[`👥┃Check Karma`](https://valkyrinllc.gitbook.io/steamlfgservice/context-actions#user-commands)** - Right-click user and select this under Apps to check karma.', inline=False) # msg_guide.add_field(name='💬┃Contact Us', value='**Technical Issues:** <:discord:902408218138005575> [**Support Server**](https://discord.gg/8DE5z5tTY8)\n**Learn More:** <:wsc_approved:504528451617685504> <#925245990087323648>', inline=False) # msg_guide.timestamp = datetime.datetime.now() # msg_guide.set_footer(text='Posted' + str(msg_guide.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # await updates_channel.send(embed=msg_guide, components=post_buttons) # # msg_guide_lfg = Embed(title='New Stellaris LFG Service!', description='Hey you, looking to **host** a new Stellaris Lobby? Lets **simplify** and enhance the hosting process for you below!', color=0xffffff) # msg_guide_lfg.add_field(name="<:wsc_approved:504528451617685504>┃Help Improve WSC LFG:", value='• Please type below **[`/register`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/register)** and provide your **Steam Friend Code**\n• When you are ready to host retun here and type **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)**\n• This will automatically create a Direct Join link into your Lobby, **no more** copy-pasting IDs for anyone!', inline=False) # msg_guide_lfg.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) # msg_guide_lfg.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) # msg_guide_lfg.timestamp = datetime.datetime.now() # msg_guide_lfg.set_footer(text=txt_footer + str(msg_guide_lfg.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # await updates_channel.send(embed=msg_guide_lfg) @client.event async def on_guild_join(guild): print(f'{client.user.name} has joined Guild: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) sql = "INSERT INTO connection_log (guild_action, guild_id, guild_name, datetime) VALUES (%s, %s, %s, %s)" val = ('join', guild.id, guild.name, datetime.datetime.now()) await mysql_commit(sql=sql, val=val) await sql_update_guilds() # Send welcome message stating to use /setup, also outline all commands if guild.id != 912156910118129684: msg_join = Embed(title='<:check:902430116234285136>┃Discord Joined', description='For commands, type `/` in any channel `' + client.user.name + '` is also in.', color=random.randint(0, 0xffffff)) msg_join.add_field(name='👮┃Slash Commands - Administrative', value='Commands for Administrators or Users with `Manage Channels` Permissions:\n\n• `/setup` - Set Global Network preference and restrict hosting channels', inline=False) msg_join.add_field(name='🕹️┃Slash Commands - Public Use', value='Commands accesible by all Server users regardless of their role permissions:\n\n• `/register` - Link a Steam Account via Friend Codes in order to use `/host`\n• `/host` - Creates a embed post and thread with in-game Lobby information\n• `/link` - Provides a direct lobby join link and steam add as friend link\n• `/karma` - Provides a user\'s karma and standing, as well as to check leaderboards.\n• `/modify` - Add or change fields on an existing LFG Post\n• `/notify` - Enable DM\'s for when a desired game is LFG\'ed for\n• `/search` - View active LFG Requests from servers in the Global Network', inline=False) msg_join.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_join.timestamp = datetime.datetime.now() msg_join.set_footer(text=txt_error + str(msg_join.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_join.set_author(name=guild.name, url=url_discord, icon_url=guild.icon.url) except AttributeError: msg_join.set_author(name=guild.name, url=url_discord, icon_url=img_unknown) pass try: await guild.system_channel.send(embed=msg_join) except: try: await guild.owner.send(embed=msg_join) except: pass pass sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (guild.id,) await mysql_commit(sql=sql, val=val) guild_params = sql_connect.fetchall() if guild_params[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite(str(guild_params[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s, guild_status = %s WHERE guild_id = %s" val = (str(global_lfg_invite), 'In', guild.id) await mysql_commit(sql=sql, val=val) except: pass pass @client.event async def on_guild_remove(guild): if guild.id != 919110752604942346: print(f'{client.user.name} was removed from Guild: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) sql = "INSERT INTO connection_log (guild_action, guild_id, guild_name, datetime) VALUES (%s, %s, %s, %s)" val = ('remove', guild.id, guild.name, datetime.datetime.now()) await mysql_commit(sql=sql, val=val) sql = "UPDATE guilds SET guild_status = %s WHERE guild_id = %s" val = ('Out', guild.id) await mysql_commit(sql=sql, val=val) sql = "SELECT * FROM posts WHERE guild_id = %s" val = (guild.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: for guild_post in sql_dict: clone_dict = guild_post['clones'] clones = {} try: clones = ast.literal_eval(clone_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE guild_id = %s" val = (guild.id,) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE guild_id = %s" val = (guild.id,) await mysql_commit(sql=sql, val=val) # ################ Setup ######################## @slash.slash_command(name='setup', description='Set Server\'s Global LFG Network preference & restrict LFG posts to certain channels and/or games!') async def setup(inter): try: inter.guild.id except AttributeError: await inter.send(embed=msg_private, ephemeral=True) pass else: await inter.send(embed=msg_process, ephemeral=True, type=5) expected_permissions = ['administrator', 'manage_channels'] if bool([item for item in inter.author.guild_permissions if ((item[0] in expected_permissions) & (item[1] is True))]): msg_network = Embed(title='🛠️┃Setup Options', description='Choose from one of the below options to modify the `' + client.user.name + '` settings for `' + inter.guild.name + '`.', color=0xffffff) msg_network.add_field(name='👮┃Slash Commands - Administrative', value='Commands for Administrators or Users with `Manage Channels` Permissions:\n\n• `/setup` - Set Global Network preference and restrict hosting channels', inline=False) msg_network.add_field(name='🕹️┃Slash Commands - Public Use', value='Commands accesible by all Server users regardless of their role permissions:\n\n• `/register` - Link a Steam Account via Friend Codes in order to use `/host`\n• `/host` - Creates a embed post and thread with in-game Lobby information\n• `/link` - Provides a direct lobby join link and steam add as friend link\n• `/karma` - Provides a user\'s karma and standing, as well as to check leaderboards.\n• `/modify` - Add or change fields on an existing LFG Post\n• `/notify` - Enable DM\'s for when a desired game is LFG\'ed for\n• `/search` - View active LFG Requests from servers in the Global Network', inline=False) msg_network.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_network.timestamp = datetime.datetime.now() msg_network.set_footer(text=txt_error + str(msg_network.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_network.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_network.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_network, components=[ActionRow(sopt_setup_choose)], ephemeral=True) else: msg_restrict = Embed(title='❌┃Missing Permissions', description='We apologize however to use `/setup` you must have the permissions Administrator or Manage Channels.', color=clr_error) msg_restrict.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_restrict.set_thumbnail(url=img_error) msg_restrict.timestamp = datetime.datetime.now() msg_restrict.set_footer(text=txt_error + str(msg_restrict.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict, ephemeral=True) # ################ Register ######################## @slash.slash_command(name='register', description='Provide a Steam Profile URL in order to enable us to generate a Lobby Invite Code for you!', options=sopt_register) async def register(inter, friend_code: int): await inter.send(embed=msg_process, ephemeral=True, type=5) sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() code = SteamID(friend_code) summary = apiauth.ISteamUser.GetPlayerSummaries(steamids=code) if (friend_code > 0) & (friend_code == code.as_32) & (friend_code != code.as_64) & bool(summary['response']['players']): uuid = summary['response']['players'][0]['steamid'] if not ids: sql = "INSERT INTO profiles (discord_id, steam_id) VALUES (%s, %s)" val = (inter.author.id, uuid) await mysql_commit(sql=sql, val=val) msg_register = Embed(title='<:check:902430116234285136>┃Profile Linked', description='Thank you `' + summary['response']['players'][0]['personaname'] + '` for providing a valid Steam Friend Code, we have succesfully linked your [Profile](' + summary['response']['players'][0]['profileurl'] + ')!', color=random.randint(0, 0xffffff)) else: sql = "UPDATE profiles SET discord_id = %s, steam_id = %s WHERE discord_id = %s" val = (inter.author.id, uuid, inter.author.id) await mysql_commit(sql=sql, val=val) msg_register = Embed(title='<:check:902430116234285136>┃Profile Updated', description='Thank you `' + summary['response']['players'][0]['personaname'] + '` for providing a valid Steam Friend Code, we have succesfully linked your updated [Profile](' + summary['response']['players'][0]['profileurl'] + ')!', color=random.randint(0, 0xffffff)) msg_register.add_field(name='✨┃Feature Overview', value='With your Profile now linked, you are able to begin use of our services to the maximum!\n\n**How to host a Lobby:**\n\n• **Step 1:** Open your Steam game of choice (**Must be a game from the Steam Store**).\n\n• **Step 2:** Return to Discord with the game open and create your LFG post using the `/host` command.\n\n• **Step 3:** Dependent on game and if you are in a Lobby or Server, our service will attach join information to your post. Our service will also create a Thread for your Post upon creation for private LFG discussion.\n\n**Important Note:**\nAlternatively, you can join others by using the `/notify` and `/search` commands or by browsing posts in any joined server with our service.\n\nAlso consider using the light-weight hosting alternative of `/link` for just Steam links instead of an Embed post.\n\nDependent on game, Join buttons are attached in order to automatically launch your application into the host\'s lobby!', inline=False) msg_register.timestamp = datetime.datetime.now() try: msg_register.set_thumbnail(url=apiauth.ISteamUser.GetPlayerSummaries(steamids=uuid)['response']['players'][0]['avatarfull'] + '?uuid=' + str(inter.author.id)) except KeyError: msg_register.set_thumbnail(url=img_steam + '?uuid=' + str(inter.author.id)) pass msg_register.set_footer(text=txt_footer + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_register, ephemeral=True) else: msg_register = Embed(title='❌┃Invalid Friend Code', description='We apologize however the Friend Code you provided is invalid.', color=clr_error) msg_register.add_field(name='❔┃Troubleshooting Steps', value='In order to associate your Discord with a valid Steam Profile, please see the below tips to providing a valid Friend code:\n\n• Please see the following provided guide on accessing your [Friend Code](https://www.howtogeek.com/671958/how-to-find-a-friend-code-in-steam/)\n\n• Ensure you are not including extra characters, spaces, or non-numbers in your response.\n\n• Please be sure to provide the Steam Friend Code of a currently active Steam Profile, not a prior deleted profile.\n\n• Consider making your profile public if not already, whilst registering to help visibility', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_register, ephemeral=True) # ################ Host ######################## @slash.slash_command(name='host', description='Whilst with a Steam game launched, provide specific parameters to build a LFG Post!', options=sopt_host) async def host(inter, description: str = '', rules: str = '', password: str = '', banner: str = ''): try: inter.guild.id except AttributeError: await inter.send(embed=msg_private, ephemeral=True) pass else: await inter.send(embed=msg_process, ephemeral=True, type=5) author_id = str(inter.author.id) guild_id = str(inter.guild.id) sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) options = sql_connect.fetchall() preference_dict = ast.literal_eval(options[0]['setup_options']) if preference_dict['host_setup'] == 'Enabled': msg_confirmation = Embed(title='<:lfg:902430116402044949>┃Submitted Details', description='See below the details of your submission using `/host`.', color=0xffffff) if bool(description) & (len(description) <= 1024): description = str(pfilter.censor(description.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Description:', value=description, inline=False) elif bool(description) & (len(description) > 1024): description = txt_long msg_confirmation.add_field(name='Description:', value=description, inline=False) if bool(rules) & (len(rules) <= 1024): rules = str(pfilter.censor(rules.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Rules:', value=rules, inline=False) elif bool(rules) & (len(rules) > 1024): rules = txt_long msg_confirmation.add_field(name='Rules:', value=rules, inline=False) if bool(password) & (len(password) <= 1024): password = str(pfilter.censor(password.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Password:', value=password, inline=False) elif bool(password) & (len(password) > 1024): password = txt_long msg_confirmation.add_field(name='Password:', value=password, inline=False) if bool(banner) & (len(banner) <= 1024): if validators.url(banner): msg_confirmation.add_field(name='Banner:', value=banner, inline=False) else: msg_confirmation.add_field(name='Banner:', value='Inputted banner url not a valid URL.', inline=False) elif bool(banner) & (len(banner) > 1024): msg_confirmation.add_field(name='Banner:', value='Inputted banner url more then 1024 characters.', inline=False) msg_confirmation.timestamp = datetime.datetime.now() msg_confirmation.set_footer(text=txt_footer + str(msg_confirmation.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirmation.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_confirmation.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass if str(inter.channel.type) == 'text': sql = "SELECT * FROM profiles WHERE discord_id = %s AND steam_id IS NOT NULL" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() sql = "SELECT lfg_restrictions FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) restrictions = sql_connect.fetchall() restrictions_dict = ast.literal_eval(restrictions[0]['lfg_restrictions']) sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) roles = sql_connect.fetchall() roles_dict = ast.literal_eval(roles[0]['lfg_roles']) if ids: cmd_author = inter.author code = SteamID(int(ids[0]['steam_id'])) summary = apiauth.ISteamUser.GetPlayerSummaries(steamids=code) restricted_single_channel = False removed_channel_ids = [] removed_role_ids = [] removed_store_urls = [] removed_store_urls_roles = [] pinged_roles = '' channel_ids_prompt = '' app_ids_prompt = '' role_ids_prompt = '' accepted_channel = True accepted_game = True playing_game = False if summary['response']['players']: if restrictions_dict['channel_ids']: if str(inter.channel.id) not in restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: if not bool([item for item in inter.guild.text_channels if (str(item.id) == channel_id)]): removed_channel_ids.append(channel_id) if removed_channel_ids: for channel_id in removed_channel_ids: restrictions_dict['channel_ids'].remove(channel_id) if len(restrictions_dict['channel_ids']) > 1: accepted_channel = False elif len(restrictions_dict['channel_ids']) == 1: for guild_channel in inter.guild.text_channels: if str(guild_channel.id) == str(restrictions_dict['channel_ids'][0]): restricted_single_channel = client.get_channel(int(restrictions_dict['channel_ids'][0])) break else: restrictions_dict['channel_ids'] = '' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: removed_store_urls.append(appid) pass if removed_store_urls: for appid in removed_store_urls: restrictions_dict['app_ids'].remove(appid) if len(restrictions_dict['app_ids']) < 1: restrictions_dict['app_ids'] = '' if len(restrictions_dict['app_ids']) >= 1: try: if summary['response']['players'][0]['gameid'] not in restrictions_dict['app_ids']: accepted_game = False except: pass elif restrictions_dict['paired_restrictions']: if str(inter.channel.id) not in restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: if not bool([item for item in inter.guild.text_channels if (str(item.id) == channel_id)]): removed_channel_ids.append(channel_id) if removed_channel_ids: for channel_id in removed_channel_ids: del restrictions_dict['paired_restrictions'][channel_id] if len(restrictions_dict['paired_restrictions']) > 1: accepted_channel = False elif len(restrictions_dict['paired_restrictions']) == 1: for channel_id in restrictions_dict['paired_restrictions']: try: appid = summary['response']['players'][0]['gameid'] except: playing_game = False pass else: if summary['response']['players'][0]['gameid'] not in restrictions_dict['paired_restrictions'][str(channel_id)]['app_ids']: accepted_game = False if accepted_game: for guild_channel in inter.guild.text_channels: if str(guild_channel.id) in restrictions_dict['paired_restrictions']: restricted_single_channel = client.get_channel(int(guild_channel.id)) break else: restrictions_dict['paired_restrictions'] = {} else: for appid in restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: removed_store_urls.append(appid) pass if removed_store_urls: for appid in removed_store_urls: restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids'].remove(appid) if len(restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids']) < 1: restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids'] = '' if len(restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids']) >= 1: try: if summary['response']['players'][0]['gameid'] not in restrictions_dict['paired_restrictions'][str(inter.channel.id)]['app_ids']: accepted_game = False except: pass try: summary['response']['players'][0]['gameid'] except: pass else: playing_game = True if accepted_game & accepted_channel & playing_game: if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: if not bool([item for item in inter.guild.roles if (str(item.id) == role_id)]): removed_role_ids.append(role_id) else: try: inter.guild.get_role(int(role_id)) except: continue else: if roles_dict['paired_roles'][role_id]: if summary['response']['players'][0]['gameid'] in roles_dict['paired_roles'][role_id]['app_ids']: pinged_roles = pinged_roles + '<@&' + str(role_id) + '> ' elif not roles_dict['paired_roles'][role_id]['app_ids']: pinged_roles = pinged_roles + '<@&' + str(role_id) + '> ' if removed_role_ids: for role_id in removed_role_ids: del roles_dict['paired_roles'][role_id] for key in roles_dict['paired_roles']: for appid in roles_dict['paired_roles'][str(key)]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: removed_store_urls_roles.append(appid) pass for key in roles_dict['paired_roles']: if removed_store_urls_roles: for appid in removed_store_urls_roles: try: roles_dict['paired_roles'][str(key)]['app_ids'].remove(appid) except ValueError: pass if len(roles_dict['paired_roles'][str(key)]['app_ids']) < 1: roles_dict['paired_roles'][str(key)]['app_ids'] = '' if bool(removed_channel_ids) | bool(removed_store_urls): if removed_channel_ids: for channel_id in removed_channel_ids: if channel_id != removed_channel_ids[-1]: channel_ids_prompt = channel_ids_prompt + channel_id + ', ' else: channel_ids_prompt = channel_ids_prompt + channel_id sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(restrictions_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_alert = Embed(title='❌┃Registered LFG Channels Detected as Deleted', description='We apologize however it seems after a user just used `/host`, we noticed some channels for LFG Restrictions you registered as no longer existing channels. This means our service was offline when said channels were originally deleted, thus they are now just being detected as such.', color=clr_error) prompt_what = 'In order to continue restricting services for `/host` in said manner that said channel setup, please consider re-running `/setup`.\n\nThe deleted Channel(s) ids were: `' + channel_ids_prompt + '`' if len(prompt_what) <= 1024: msg_alert.add_field(name='❔┃What to do', value=prompt_what, inline=False) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) channels = sql_connect.fetchall() lfg_restrictions = '' restrictions_dict = ast.literal_eval(channels[0]['lfg_restrictions']) if restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - All games allowed\n' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: lfg_restrictions = lfg_restrictions + '• Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/\n' pass else: lfg_restrictions = lfg_restrictions + '• [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/\n' elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - ' if restrictions_dict['paired_restrictions'][channel_id]['app_ids']: for appid in restrictions_dict['paired_restrictions'][channel_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_restrictions = lfg_restrictions + 'All games allowed' lfg_restrictions = lfg_restrictions + '\n' else: lfg_restrictions = '• No restrictions currently in place for any channels or games. `/host` can be used in any channel for any game.' prompt_restrictions = '`' + inter.guild.name + '` Restrictions: \n\n' + lfg_restrictions if len(prompt_restrictions) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences', value=prompt_restrictions, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await inter.guild.owner.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await inter.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) if len(prompt_what) > 1024: await inter.guild.owner.send(content='❔┃What to do\n\n' + prompt_what) except: await inter.guild.system_channel.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await inter.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) if len(prompt_what) > 1024: await inter.guild.system_channel.send(content='❔┃What to do\n\n' + prompt_what) pass if removed_store_urls: for app_id in removed_store_urls: if app_id != removed_store_urls[-1]: app_ids_prompt = app_ids_prompt + 'https://store.steampowered.com/app/' + app_id + '/, ' else: app_ids_prompt = app_ids_prompt + 'https://store.steampowered.com/app/' + app_id + '/' sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(restrictions_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_alert = Embed(title='❌┃Registered LFG Games Detected as Deleted', description='We apologize however it seems after a user just used `/host`, we noticed some games for LFG Restrictions you registered as no longer being listed on the Steam Store. This means our service can no longer handle LFG requests for said titles, please ensure to continue only hosting for games listed on the Steam Store.', color=clr_error) prompt_what = 'In order to continue restricting services for `/host` new games, please consider re-running `/setup`.\n\nThe deleted Game(s) URLs were: `' + app_ids_prompt + '`' if len(prompt_what) <= 1024: msg_alert.add_field(name='❔┃What to do', value=prompt_what, inline=False) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) channels = sql_connect.fetchall() lfg_restrictions = '' restrictions_dict = ast.literal_eval(channels[0]['lfg_restrictions']) if restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - All games allowed\n' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: lfg_restrictions = lfg_restrictions + '• Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/\n' pass else: lfg_restrictions = lfg_restrictions + '• [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/\n' elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - ' if restrictions_dict['paired_restrictions'][channel_id]['app_ids']: for appid in restrictions_dict['paired_restrictions'][channel_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_restrictions = lfg_restrictions + 'All games allowed' lfg_restrictions = lfg_restrictions + '\n' else: lfg_restrictions = '• No restrictions currently in place for any channels or games. `/host` can be used in any channel for any game.' prompt_restrictions = '`' + inter.guild.name + '` Restrictions: \n\n' + lfg_restrictions if len(prompt_restrictions) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences', value=prompt_restrictions, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await inter.guild.owner.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await inter.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) if len(prompt_what) > 1024: await inter.guild.owner.send(content='❔┃What to do\n\n' + prompt_what) except: await inter.guild.system_channel.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await inter.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) if len(prompt_what) > 1024: await inter.guild.system_channel.send(content='❔┃What to do\n\n' + prompt_what) pass if bool(removed_role_ids) | bool(removed_store_urls_roles): if removed_role_ids: for role_id in removed_role_ids: if role_id != removed_role_ids[-1]: role_ids_prompt = role_ids_prompt + role_id + ', ' else: role_ids_prompt = role_ids_prompt + role_id sql = "UPDATE guilds SET lfg_roles = %s WHERE guild_id = %s" val = (str(roles_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_alert = Embed(title='❌┃Roles for LFG Pings Detected as Deleted', description='We apologize however it seems after a user just used `/host`, we noticed some roles for LFG Role Pings you paired as no longer existing on your Discord Server. This means our service was offline when said roles were originally deleted, thus they are now just being detected as such.', color=clr_error) prompt_what = 'In order to continue pinging roles on `/host` usage, please consider re-running `/setup`.\n\nThe deleted Role(s) ids were: `' + role_ids_prompt + '`' if len(prompt_what) <= 1024: msg_alert.add_field(name='❔┃What to do', value=prompt_what, inline=False) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) roles = sql_connect.fetchall() lfg_roles = '' roles_dict = ast.literal_eval(roles[0]['lfg_roles']) if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: try: guild_role = inter.guild.get_role(int(role_id)) guild_role_name = guild_role.name except: lfg_roles = lfg_roles + '• `Role ID: ' + str(role_id) + '` - ' continue else: lfg_roles = lfg_roles + '• `' + str(guild_role.name) + '` - ' if roles_dict['paired_roles'][role_id]['app_ids']: for appid in roles_dict['paired_roles'][role_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_roles = lfg_roles + 'Will be pinged on `/host` usage for all games' lfg_roles = lfg_roles + '\n' else: lfg_roles = '• No role pings currently in place any longer for games.\n\n**Note:** To update role pings in the future simply re-run `/setup`' prompt_roles = '`' + inter.guild.name + '` LFG Role Pings: \n\n' + lfg_roles if len(prompt_roles) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences', value=prompt_roles, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await inter.guild.owner.send(embed=msg_alert) if len(prompt_roles) > 1024: await inter.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) if len(prompt_what) > 1024: await inter.guild.owner.send(content='❔┃What to do\n\n' + prompt_what) except: await inter.guild.system_channel.send(embed=msg_alert) if len(prompt_roles) > 1024: await inter.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) if len(prompt_what) > 1024: await inter.guild.system_channel.send(content='❔┃What to do\n\n' + prompt_what) pass if removed_store_urls_roles: for app_id in removed_store_urls_roles: if app_id != removed_store_urls_roles[-1]: app_ids_prompt = app_ids_prompt + 'https://store.steampowered.com/app/' + app_id + '/, ' else: app_ids_prompt = app_ids_prompt + 'https://store.steampowered.com/app/' + app_id + '/' sql = "UPDATE guilds SET lfg_roles = %s WHERE guild_id = %s" val = (str(roles_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_alert = Embed(title='❌┃Games for LFG Role Pings Detected as Deleted', description='We apologize however it seems after a user just used `/host`, we noticed some games for LFG Role Pings you paired as no longer being listed on the Steam Store. This means our service will no longer ping said roles on `/host` usage for stated games.', color=clr_error) prompt_what = 'In order to continue pinging said roles for games on `/host` usage, please consider re-running `/setup`.\n\nThe deleted Game(s) URLs were: `' + app_ids_prompt + '`' if len(prompt_what) <= 1024: msg_alert.add_field(name='❔┃What to do', value=prompt_what, inline=False) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) roles = sql_connect.fetchall() lfg_roles = '' roles_dict = ast.literal_eval(roles[0]['lfg_roles']) if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: try: guild_role = inter.guild.get_role(int(role_id)) guild_role_name = guild_role.name except: lfg_roles = lfg_roles + '• `Role ID: ' + str(role_id) + '` - ' continue else: lfg_roles = lfg_roles + '• `' + str(guild_role.name) + '` - ' if roles_dict['paired_roles'][role_id]['app_ids']: for appid in roles_dict['paired_roles'][role_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_roles = lfg_roles + 'Will be pinged on `/host` usage for all games' lfg_roles = lfg_roles + '\n' else: lfg_roles = '• No role pings currently in place any longer for games.\n\n**Note:** To update role pings in the future simply re-run `/setup`' prompt_roles = '`' + inter.guild.name + '` LFG Role Pings: \n\n' + lfg_roles if len(prompt_roles) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences', value=prompt_roles, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await inter.guild.owner.send(embed=msg_alert) if len(prompt_roles) > 1024: await inter.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) if len(prompt_what) > 1024: await inter.guild.owner.send(content='❔┃What to do\n\n' + prompt_what) except: await inter.guild.system_channel.send(embed=msg_alert) if len(prompt_roles) > 1024: await inter.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) if len(prompt_what) > 1024: await inter.guild.system_channel.send(content='❔┃What to do\n\n' + prompt_what) pass if (accepted_channel is False) or (accepted_game is False): await inter.followup(embed=msg_confirmation, ephemeral=True) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) channels = sql_connect.fetchall() lfg_restrictions = '' restrictions_dict = ast.literal_eval(channels[0]['lfg_restrictions']) if restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: lfg_restrictions = lfg_restrictions + '• <#' + str( channel_id) + '> - All games allowed\n' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: lfg_restrictions = lfg_restrictions + '• Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/\n' pass else: lfg_restrictions = lfg_restrictions + '• [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)\n' elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - ' if restrictions_dict['paired_restrictions'][channel_id]['app_ids']: for appid in restrictions_dict['paired_restrictions'][channel_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_restrictions = lfg_restrictions + 'All games allowed' lfg_restrictions = lfg_restrictions + '\n' else: lfg_restrictions = '• No restrictions currently in place for any channels or games. `/host` can be used in any channel for any game.' if accepted_channel is False: msg_alert = Embed(title='❌┃Forbidden Channel for LFG', description='We apologize however due to current server LFG restrictions you cannot use `/host` in this channel.', color=clr_error) if len(lfg_restrictions) <= 1024: msg_alert.add_field(name='❔┃Channels & Games you can LFG in', value=lfg_restrictions, inline=False) else: msg_alert = Embed(title='❌┃Forbidden Game for LFG', description='We apologize however due to current server LFG restrictions you cannot use `/host` for this game.', color=clr_error) if len(lfg_restrictions) <= 1024: msg_alert.add_field(name='❔┃Games you can LFG for', value=lfg_restrictions, inline=False) msg_alert.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_error + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_alert.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_alert, ephemeral=True) if len(lfg_restrictions) > 1024: if accepted_channel is False: await inter.followup(content='❔┃Channels & Games you can LFG in\n\n' + lfg_restrictions, ephemeral=True) else: await inter.followup(content='❔┃Games you can LFG for\n\n' + lfg_restrictions, ephemeral=True) else: payload = {'key': os.environ['API_AUTH'], 'steamid': ids[0]['steam_id'], 'count': '100'} response_games = requests.get('https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/', params=payload) try: response_games.json()['response']['games'] except KeyError: msg_error_profile = Embed(title='🛑┃Steam Profile NOT Fully Public', description='We apologize however in order to use `/host` you must **have certain Profile settings public.** See the below steps on **opening your Profile\'s Privacy settings to Public.**', color=clr_error) msg_error_profile.add_field(name='❕┃You MUST Set Steam Profile to Public', value='**Only public profiles can use `/host`**, please use the following steps to set required settings to Public visibility:\n\n• **Step 1:** [Visit ' + summary['response']['players'][0]['personaname'] + '\'s Settings](' + url_redirect + 'steam://openurl/' + summary['response']['players'][0]['profileurl'] + 'edit/settings)\n• **Step 2:** Change `My profile` to **Public**\n• **Step 3:** Change `Game details` to **Public**\n• **Step 4:** Change `Game details` sub-option checkbox `Always keep my total playtime private even if users can see my game details.` to be **Un-Checked**\n\nAfter all steps completed, you can **immediately** begin using `/host` without issue!', inline=False) msg_error_profile.add_field(name='❔┃Why this is Required', value='In order to build your LFG Post we query the Steam API to pull information regarding your currently launched game.\n\nThis makes it so our service can support any title on Steam, all without you having to type what specific game to LFG for.\n\nWithout a game currently launched and the ability to read your recently played games we cannot determine what game you intend to LFG for.', inline=False) msg_error_profile.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_profile.set_thumbnail(url=img_error) msg_error_profile.timestamp = datetime.datetime.now() msg_error_profile.set_image(url='https://media1.giphy.com/media/1gdie7opvzRZv1yy9n/giphy.gif?cid=ecf05e47d2g2vc9zgnadadykbm9emn39xthu068jhlubrkac&rid=giphy.gif&ct=g') msg_error_profile.set_footer(text=txt_error + str(msg_error_profile.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_error_profile, ephemeral=True) pass else: try: appid = summary['response']['players'][0]['gameid'] except KeyError: msg_error_game = Embed(title='🛑┃No Steam Game Launched', description='We apologize however in order to use `/host` you must first launch your game of choice to LFG for.\n\nPlease ensure it is not a Non-Steam manually added Game launched.', color=clr_error) msg_error_game.add_field(name='❔┃Why this is Required', value='In order to build your LFG Post we query the Steam API to pull information regarding your currently launched game.\n\nPlease ensure you have a game launched, also ensure your Steam Profile visibility is public like below as to detect said launched game.', inline=False) msg_error_game.add_field(name='❕┃Remember to Set Steam Profile to Public', value='**Only public profiles can use `/host`**, please use the following steps to set required settings to Public visibility:\n\n• **Step 1:** [Visit ' + summary['response']['players'][0]['personaname'] + '\'s Settings](' + url_redirect + 'steam://openurl/' + summary['response']['players'][0]['profileurl'] + 'edit/settings)\n• **Step 2:** Change `My profile` to **Public**\n• **Step 3:** Change `Game details` to **Public**\n• **Step 4:** Change `Game details` sub-option checkbox `Always keep my total playtime private even if users can see my game details.` to be **Un-Checked**\n\nAfter all steps completed, you can **immediately** begin using `/host` without issue!', inline=False) msg_error_game.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_game.set_thumbnail(url=img_error) msg_error_game.timestamp = datetime.datetime.now() msg_error_game.set_image(url='https://media1.giphy.com/media/WuaxwLWrJQNPLHN3n9/giphy.gif?cid=ecf05e47sz5rg1r365interrq729z3p4txnydpaji95r1uohwz&rid=giphy.gif&ct=g') msg_error_game.set_footer(text=txt_error + str(msg_error_game.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_error_game, ephemeral=True) pass else: sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) guild_params = sql_connect.fetchall() sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) setup_options = sql_connect.fetchall() preference_dict = ast.literal_eval(setup_options[0]['setup_options']) msg_post_color = random.randint(0, 0xffffff) msg_post = Embed(title='<:lfg:902430116402044949>┃LFG Requestor', description='<@' + str(inter.author.id) + '>', color=msg_post_color) msg_post.timestamp = datetime.datetime.now() try: msg_post.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_post.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: msg_post.set_thumbnail(url=apiauth.ISteamUser.GetPlayerSummaries(steamids=int(ids[0]['steam_id']))['response']['players'][0]['avatarfull'] + '?uuid=' + str(inter.author.id)) except KeyError: try: msg_post.set_thumbnail(url=inter.author.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass pass app_name = summary['response']['players'][0]['gameextrainfo'] appid = summary['response']['players'][0]['gameid'] try: msg_post.set_author(name=app_name + ' - LFG', url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_post.set_author(name=app_name + ' - LFG', url=url_discord, icon_url=img_unknown) pass try: avatar = summary['response']['players'][0]['avatarfull'] except KeyError: try: msg_post.set_thumbnail(url=inter.author.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass else: msg_post.set_thumbnail(url=avatar + '?uuid=' + str(inter.author.id)) app_icon = img_unknown for idx, values in enumerate(response_games.json()['response']['games']): if str(response_games.json()['response']['games'][idx]['appid']) == appid: app_icon = 'http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/' + appid + '/' + response_games.json()['response']['games'][idx]['img_icon_url'] + '.jpg' if not app_icon: app_icon = img_unknown msg_post.set_author(name=app_name + ' - LFG', url=url_redirect + 'steam://url/StoreAppPage/' + appid + '/', icon_url=app_icon) if preference_dict['banner_setup'] == 'Enabled': msg_post.set_image(url='https://cdn.akamai.steamstatic.com/steam/apps/' + appid + '/header.jpg') break if bool(description) & (description != txt_long): msg_post.add_field(name='Description:', value=description.replace(r'\n', '\n'), inline=False) else: msg_post.add_field(name='Description:', value='`' + inter.author.name + '` is now looking for others!\n\nAdd the host on Steam & join their game below!', inline=False) if bool(rules) & (rules != txt_long): msg_post.add_field(name='Rules:', value=rules.replace(r'\n', '\n'), inline=False) if bool(password) & (password != txt_long): msg_post.add_field(name='Password:', value=password.replace(r'\n', '\n'), inline=False) if bool(banner) & (len(banner) <= 1024): if validators.url(banner): msg_post.set_image(url=banner) post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.secondary, label="", emoji='👍🏼', custom_id='post_karma'), Button(style=ButtonStyle.secondary, label="", emoji='🔔', custom_id='post_notify'), Button(style=ButtonStyle.secondary, label="", emoji='🗑️', custom_id='post_close') )] sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) host_karma = sql_connect.fetchall() footer_note = '\n' + str(host_karma[0]['karma']) + ' Karma' no_join = False try: serverip = summary['response']['players'][0]['gameserverip'] except KeyError: try: lobbyid = summary['response']['players'][0]['lobbysteamid'] except KeyError: no_join = True pass else: if appid == '813780': found_match = False apicheck_start = datetime.datetime.now() while True: for match in aoe2_apiauth.get_open_lobbies('aoe2de', True): if (lobbyid == match['lobby_id']) or (any(player['steam_id'] == summary['response']['players'][0]['steamid'] for player in match['players'])): join_link = 'aoe2de://0/' + match['match_id'] footer_note = footer_note + ' • Lobby ID: ' + 'aoe2de://0/' + match['match_id'] found_match = True if (not bool(description)) or (description == txt_long): try: if match['name']: msg_post.set_field_at(index=0, name='Description:', value='`' + inter.author.name + '` is now looking for others to play ```ansi\n[1;3' + str(random.randint(1,6)) + 'm' + match['name'] + '[0m```\n\nAdd the host on Steam & join their game below!', inline=False) except: pass break if (datetime.datetime.now() > apicheck_start + timedelta(seconds=10)) | found_match: break if not found_match: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) join_link = 'steam://joinlobby/' + appid + '/' + lobbyid else: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) join_link = 'steam://joinlobby/' + appid + '/' + lobbyid post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.secondary, label="", emoji='👍🏼', custom_id='post_karma'), Button(style=ButtonStyle.secondary, label="", emoji='🔔', custom_id='post_notify'), Button(style=ButtonStyle.secondary, label="", emoji='🗑️', custom_id='post_close') )] msg_post.set_footer(text='Use the below Buttons to interact to join!\nLFG Posted' + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) pass else: footer_note = footer_note + ' • Server IP: ' + str(serverip) if password: join_link = 'steam://connect/' + serverip + '/' + password[:1024] else: join_link = 'steam://connect/' + serverip post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.secondary, label="", emoji='👍🏼', custom_id='post_karma'), Button(style=ButtonStyle.secondary, label="", emoji='🔔', custom_id='post_notify'), Button(style=ButtonStyle.secondary, label="", emoji='🗑️', custom_id='post_close') )] msg_post.set_footer(text='Use the below Buttons to interact to join!\nLFG Posted' + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) if restricted_single_channel is not False: lfg_channel = restricted_single_channel else: lfg_channel = inter.channel if preference_dict['thread_setup'] == 'Enabled': msg_post.set_footer(text='Add the Host on Steam and join the Thread!' + footer_note + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) else: msg_post.set_footer(text='Add the Host on Steam and message them!' + footer_note + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) sql = "SELECT * FROM host_log WHERE discord_id = %s AND guild_id = %s AND post_time > date_sub(%s, interval 15 minute)" val = (inter.author.id, inter.guild.id, msg_post.timestamp) await mysql_commit(sql=sql, val=val) recent_origin_posts = sql_connect.fetchall() if not (bool(removed_channel_ids) | bool(removed_store_urls) | bool(removed_role_ids) | bool(removed_store_urls_roles)): if (len(recent_origin_posts) < 2) and (bool(pinged_roles)): if int(guild_params[0]['lfg_remove']) == 0: lfg_post = await lfg_channel.send(content=pinged_roles, embed=msg_post, components=post_buttons) else: lfg_post = await lfg_channel.send(content=pinged_roles, embed=msg_post, components=post_buttons, delete_after=int(guild_params[0]['lfg_remove'])) else: if int(guild_params[0]['lfg_remove']) == 0: lfg_post = await lfg_channel.send(embed=msg_post, components=post_buttons) else: lfg_post = await lfg_channel.send(embed=msg_post, components=post_buttons, delete_after=int(guild_params[0]['lfg_remove'])) lfg_post_link = [ActionRow(Button(style=ButtonStyle.link, label="LFG Post", emoji='📑', url=lfg_post.jump_url))] if no_join is True: msg_confirmation.add_field(name='❗┃No Join Link Generated:', value='No joined Lobby or Server detected, thus no `🕹️ Join Game` button will be provided.', inline=False) await inter.followup(embed=msg_confirmation, components=lfg_post_link, ephemeral=True) else: if (len(recent_origin_posts) < 2) and (bool(pinged_roles)): if int(guild_params[0]['lfg_remove']) == 0: lfg_post = await lfg_channel.send(content=pinged_roles, embed=msg_post, components=post_buttons) else: lfg_post = await lfg_channel.send(content=pinged_roles, embed=msg_post, components=post_buttons, delete_after=int(guild_params[0]['lfg_remove'])) else: if int(guild_params[0]['lfg_remove']) == 0: lfg_post = await lfg_channel.send(embed=msg_post, components=post_buttons) else: lfg_post = await lfg_channel.send(embed=msg_post, components=post_buttons, delete_after=int(guild_params[0]['lfg_remove'])) lfg_post_link = [ActionRow(Button(style=ButtonStyle.link, label="LFG Post", emoji='📑', url=lfg_post.jump_url))] if no_join is True: msg_confirmation.add_field(name='❗┃No Join Link Generated:', value='No joined Lobby or Server detected, thus no `🕹️ Join Game` button will be provided.', inline=False) try: await cmd_author.send(embed=msg_confirmation, components=lfg_post_link) except: pass if preference_dict['thread_setup'] == 'Enabled': lfg_thread = await lfg_post.create_thread(name='👥┃LFG Request Thread - ' + inter.author.name, auto_archive_duration=60) components = str(lfg_post.components) urls = re.findall(r'(https?://[^\s]+)', components) if len(urls) > 1: thread_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.secondary, label="", emoji='🔔', custom_id='post_notify'), Button(style=ButtonStyle.secondary, label="Close Thread", emoji='🗑️', custom_id='thread_close') )] else: thread_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.secondary, label="", emoji='🔔', custom_id='post_notify'), Button(style=ButtonStyle.secondary, label="Close Thread", emoji='🗑️', custom_id='thread_close') )] msg_thread = Embed(title=lfg_post.embeds[0].title, description=lfg_post.embeds[0].description, color=msg_post_color) msg_thread.add_field(name='<:discord:902408218138005575>┃LFG Request Thread', value='Please use this thread to coordinate friend requests and in-game plans for the below LFG hosted by <@' + str(inter.author.id) + '>', inline=False) msg_thread.add_field(name='<:steam:902408194440175627>┃Interested in Hosting', value='`Looking to start your own LFG Request?`\n\nRun command `/register`. then run command `/host` with your desired Steam Game open!', inline=False) msg_thread.set_thumbnail(url=lfg_post.embeds[0].thumbnail.url) msg_thread.timestamp = datetime.datetime.now() msg_thread.set_footer(text=lfg_post.embeds[0].footer.text.replace('Add the Host on Steam and join the Thread!', 'Add the Host on Steam and discuss plans below!'), icon_url=lfg_post.embeds[0].footer.icon_url) msg_thread.set_author(name=lfg_post.embeds[0].author.name, url=lfg_post.embeds[0].author.url, icon_url=lfg_post.embeds[0].author.icon_url) await lfg_thread.send(embed=msg_thread, components=thread_buttons) await lfg_thread.add_user(inter.author) sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) invite_checks = sql_connect.fetchall() if invite_checks[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite( str(invite_checks[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(inter.guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), inter.guild.id) await mysql_commit(sql=sql, val=val) except: pass pass sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) preference = sql_connect.fetchall() internal_invites = ast.literal_eval(preference[0]['setup_options']) if preference[0]['global_lfg_opt'] == 'In': if preference_dict['active_setup'] == 'Disabled': sql = "SELECT * FROM posts WHERE discord_id = %s AND guild_id = %s" val = (inter.author.id, inter.guild.id) await mysql_commit(sql=sql, val=val) posts_active = sql_connect.fetchall() for post in posts_active: try: channel = client.get_channel(int(post['channel_id'])) post = await channel.fetch_message(int(post['message_id'])) await post.delete() except: sql = "SELECT * FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message( int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) continue sql_connect.execute("SELECT * FROM posts") posts_active = sql_connect.fetchall() for matching_post in posts_active: time_limit = matching_post['post_time'] + timedelta(minutes=90) if datetime.datetime.now() >= time_limit: sql = "SELECT * FROM posts WHERE message_id = %s" val = (matching_post['message_id'],) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message( int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (matching_post['message_id'],) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (matching_post['message_id'],) await mysql_commit(sql=sql, val=val) sql = "SELECT * FROM posts WHERE discord_id = %s AND app_id = %s" val = (inter.author.id, appid) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: for guild_post in sql_dict: clone_dict = guild_post['clones'] clones = {} try: clones = ast.literal_eval(clone_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE discord_id = %s AND app_id = %s" val = (inter.author.id, appid) await mysql_commit(sql=sql, val=val) sql = "INSERT INTO posts (guild_id, discord_id, channel_id, message_id, app_id, post_time) VALUES (%s, %s, %s, %s, %s, %s)" val = (inter.guild.id, inter.author.id, lfg_post.channel.id, lfg_post.id, appid, msg_post.timestamp) await mysql_commit(sql=sql, val=val) sql_connect.execute("SELECT * FROM notifications") users_notify = sql_connect.fetchall() if preference[0]['global_lfg_opt'] == 'In': for user in users_notify: if user['discord_id'] != str(inter.author.id): user_app_ids = ast.literal_eval(user['subscriptions']) subscribed_game = False subscribed_user_game = False subscribed_user = False if appid in user_app_ids['app_ids']: subscribed_game = True if str(inter.author.id) in user_app_ids['paired_notifications']: if user_app_ids['paired_notifications'][str(inter.author.id)]: if appid in user_app_ids['paired_notifications'][str(inter.author.id)]: subscribed_user_game = True else: subscribed_user = True if subscribed_game or subscribed_user_game or subscribed_user: button_prompt = '' button_prompt_any = '' notification_prompt = '' user_to_notify = client.get_user(int(user['discord_id'])) payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if subscribed_user_game or subscribed_user: if subscribed_user_game: if user_to_notify in inter.guild.members: notification_prompt = notification_prompt + 'See below a notification of a new LFG Post for Discord User, <@' + str(inter.author.id) + '> now playing Steam Game `' + response[appid]['data']['name'] + '`' else: notification_prompt = notification_prompt + 'See below a notification of a new LFG Post for Discord User, <@' + str(inter.author.id) + '> aka `' + str(inter.author) + '`, now playing Steam Game `' + response[appid]['data']['name'] + '`' button_prompt = "Stop Notifications for '" + str(inter.author.name) + "'" + " playing `" + str(response[appid]['data']['name']) + "'" button_prompt_any = "Stop All Notifications for '" + str(inter.author.name) + "'" elif subscribed_user: if user_to_notify in inter.guild.members: notification_prompt = notification_prompt + 'See below a notification of a new LFG Post for Discord User, <@' + str(inter.author.id) + '>' else: notification_prompt = notification_prompt + 'See below a notification of a new LFG Post for Discord User, <@' + str(inter.author.id) + '> aka `' + str(inter.author) + '`' button_prompt = "Stop Notifications for '" + str(inter.author.name) + "' playing any game" elif subscribed_game: notification_prompt = notification_prompt + 'See below a notification of a new LFG Post for Steam Game, `' + response[appid]['data']['name'] + '`' button_prompt = "Stop Notifications for '" + str(response[appid]['data']['name']) + "'" if notification_prompt: notification_prompt = notification_prompt + '\n' notification_prompt = notification_prompt + '❔┃**Update Notifications:** Note, at anytime re-run `/notify` in order to update your current subscriptions.' sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (lfg_post.guild.id,) await mysql_commit(sql=sql, val=val) invite_checks = sql_connect.fetchall() notify_embed = lfg_post.embeds[0] if user_to_notify not in inter.guild.members: notify_embed.description = '`' + str(inter.author) + '`' if invite_checks[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite(str(invite_checks[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(lfg_post.guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), lfg_post.guild.id) await mysql_commit(sql=sql, val=val) except: pass pass sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (lfg_post.guild.id,) await mysql_commit(sql=sql, val=val) invite = sql_connect.fetchall() components = str(lfg_post.components) urls = re.findall(r'(https?://[^\s]+)', components) if len(urls) > 1: if internal_invites['internal_invites'] == 'Enabled': if subscribed_user_game: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop'), Button(style=ButtonStyle.secondary, label=button_prompt_any, emoji='🔕', custom_id='notify_stop_any') )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop') )] else: if subscribed_user_game: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop'), Button(style=ButtonStyle.secondary, label=button_prompt_any, emoji='🔕', custom_id='notify_stop_any') )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop') )] else: if internal_invites['internal_invites'] == 'Enabled': if subscribed_user_game: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop'), Button(style=ButtonStyle.secondary, label=button_prompt_any, emoji='🔕', custom_id='notify_stop_any') )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop') )] else: if subscribed_user_game: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop'), Button(style=ButtonStyle.secondary, label=button_prompt_any, emoji='🔕', custom_id='notify_stop_any') )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) ), ActionRow( Button(style=ButtonStyle.secondary, label=button_prompt, emoji='🔕', custom_id='notify_stop') )] try: await user_to_notify.send(content='<:check:902430116234285136>┃**LFG Notification:** ' + notification_prompt, embed=notify_embed, components=post_buttons, delete_after=172800) except: pass if preference_dict['active_setup'] == 'Disabled': try: async for msg in lfg_post.channel.history(): if msg.id != lfg_post.id: if msg.author.id == client.user.id: if msg.embeds: if (msg.embeds[0].title == '<:lfg:902430116402044949>┃LFG Requestor') & (msg.embeds[0].thumbnail.url.split('?uuid=')[1] == str(inter.author.id)): await msg.delete() except: pass if preference[0]['global_lfg_opt'] == 'In': sql = "SELECT * FROM host_log WHERE discord_id = %s AND post_time > date_sub(%s, interval 30 minute)" val = (inter.author.id, msg_post.timestamp) await mysql_commit(sql=sql, val=val) recent_posts = sql_connect.fetchall() sql = "INSERT INTO host_log (guild_id, discord_id, channel_id, message_id, post_time) VALUES (%s, %s, %s, %s, %s)" val = (inter.guild.id, inter.author.id, lfg_post.channel.id, lfg_post.id, msg_post.timestamp) await mysql_commit(sql=sql, val=val) sql_connect.execute("SELECT * FROM notifications WHERE guild_id IS NOT NULL") notifications_dicts = sql_connect.fetchall() if notifications_dicts: for guild in notifications_dicts: settings_dict = ast.literal_eval(guild['notifications']) try: specific_guild = client.get_guild(int(guild['guild_id'])) except: pass else: if specific_guild: if settings_dict: for pair in settings_dict: if str(pair) == str(lfg_post.channel.id): break else: if settings_dict[pair]: for app_dict in settings_dict[pair]: app_dict_id = list(app_dict.keys())[0] if (str(appid) == str(app_dict_id)) | (settings_dict[pair] == []): userids = next(iter((app_dict.items())))[1] new_embed = lfg_post.embeds[0] post_host = await client.fetch_user(int(lfg_post.embeds[0].thumbnail.url.split('?uuid=')[1])) if post_host not in specific_guild.members: new_embed.description = '<@' + str(post_host.id) + '> aka `' + str(post_host) + '`' new_embed.set_author(name=app_name + ' - Global LFG', url=url_redirect + 'steam://url/StoreAppPage/' + appid + '/', icon_url=app_icon) new_embed.title = '<:logo:908953639085821973>┃LFG Requestor' footer_note = '\n' + new_embed.footer.text.split('\n')[1].strip() if str(guild['guild_id']) == str(lfg_post.guild.id): new_embed.set_footer(text='Direct Message on Discord and Add the Host on Steam!' + footer_note, icon_url=img_tip) else: new_embed.set_footer(text='This is an external LFG Post, Add the Host on Steam!' + footer_note, icon_url=img_tip) sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (specific_guild.id,) await mysql_commit(sql=sql, val=val) specific_guild_roles = sql_connect.fetchall() specific_guild_roles_dict = ast.literal_eval(specific_guild_roles[0]['lfg_roles']) specific_guild_removed_store_urls_roles = [] specific_guild_removed_role_ids = [] specific_guild_pinged_roles = '' if specific_guild_roles_dict['paired_roles']: for role_id in specific_guild_roles_dict['paired_roles']: if not bool([item for item in specific_guild.roles if (str(item.id) == role_id)]): specific_guild_removed_role_ids.append(role_id) else: try: specific_guild.get_role(int(role_id)) except: continue else: if specific_guild_roles_dict['paired_roles'][role_id]: if summary['response']['players'][0]['gameid'] in specific_guild_roles_dict['paired_roles'][role_id]['app_ids']: specific_guild_pinged_roles = specific_guild_pinged_roles + '<@&' + str(role_id) + '> ' elif not specific_guild_roles_dict['paired_roles'][role_id]['app_ids']: specific_guild_pinged_roles = specific_guild_pinged_roles + '<@&' + str(role_id) + '> ' if specific_guild_removed_role_ids: for role_id in specific_guild_removed_role_ids: del specific_guild_roles_dict['paired_roles'][role_id] for key in specific_guild_roles_dict['paired_roles']: for role_appid in specific_guild_roles_dict['paired_roles'][str(key)]['app_ids']: payload = {'appids': role_appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[role_appid]['data'] except KeyError: specific_guild_removed_store_urls_roles.append(role_appid) pass for key in specific_guild_roles_dict['paired_roles']: if specific_guild_removed_store_urls_roles: for role_appid in specific_guild_removed_store_urls_roles: try: specific_guild_roles_dict['paired_roles'][str(key)]['app_ids'].remove(role_appid) except ValueError: pass if len(specific_guild_roles_dict['paired_roles'][str(key)]['app_ids']) < 1: specific_guild_roles_dict['paired_roles'][str(key)]['app_ids'] = '' sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (guild['guild_id'],) await mysql_commit(sql=sql, val=val) setup_dict = ast.literal_eval(sql_connect.fetchall()[0]['setup_options']) if (setup_dict['external_invites'] == 'Enabled') and (internal_invites['internal_invites'] == 'Enabled'): if not no_join: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=preference[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) )] else: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=preference[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) )] else: if not no_join: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) )] else: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) )] cloned_msg = '' sent_clone = False if userids: if (author_id in userids) | (guild_id in userids): try: channel = client.get_channel(int(pair)) if (len(recent_posts) < 2) and (bool(specific_guild_pinged_roles)): cloned_msg = await channel.send(content=specific_guild_pinged_roles, embed=new_embed, components=clone_buttons) else: cloned_msg = await channel.send(embed=new_embed, components=clone_buttons) sent_clone = True except: pass else: break else: try: channel = client.get_channel(int(pair)) if (len(recent_posts) < 2) and (bool(specific_guild_pinged_roles)): cloned_msg = await channel.send(content=specific_guild_pinged_roles, embed=new_embed, components=clone_buttons) else: cloned_msg = await channel.send(embed=new_embed, components=clone_buttons) sent_clone = True except: pass if sent_clone: sql = "SELECT * FROM posts WHERE message_id = %s" val = (lfg_post.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall()[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass clones[pair] = str(cloned_msg.id) sql = "UPDATE posts SET clones = %s WHERE message_id = %s" val = (str(clones), lfg_post.id) await mysql_commit(sql=sql, val=val) else: new_embed = lfg_post.embeds[0] post_host = await client.fetch_user(int(lfg_post.embeds[0].thumbnail.url.split('?uuid=')[1])) if post_host not in specific_guild.members: new_embed.description = '<@' + str(post_host.id) + '> aka `' + str(post_host) + '`' new_embed.set_author(name=app_name + ' - Global LFG', url=url_redirect + 'steam://url/StoreAppPage/' + appid + '/', icon_url=app_icon) new_embed.title = '<:logo:908953639085821973>┃LFG Requestor' footer_note = '\n' + new_embed.footer.text.split('\n')[1].strip() if str(guild['guild_id']) == str(lfg_post.guild.id): new_embed.set_footer(text='Direct Message on Discord and Add the Host on Steam!' + footer_note, icon_url=img_tip) else: new_embed.set_footer(text='This is an external LFG Post, Add the Host on Steam!' + footer_note, icon_url=img_tip) sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (guild['guild_id'],) await mysql_commit(sql=sql, val=val) setup_dict = ast.literal_eval(sql_connect.fetchall()[0]['setup_options']) if (setup_dict['external_invites'] == 'Enabled') and (internal_invites['internal_invites'] == 'Enabled'): if not no_join: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=preference[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) )] else: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=preference[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=lfg_post.jump_url) )] else: if not no_join: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=url_redirect + join_link), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) )] else: clone_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid']) )] sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (specific_guild.id,) await mysql_commit(sql=sql, val=val) specific_guild_roles = sql_connect.fetchall() specific_guild_roles_dict = ast.literal_eval(specific_guild_roles[0]['lfg_roles']) specific_guild_removed_store_urls_roles = [] specific_guild_removed_role_ids = [] specific_guild_pinged_roles = '' if specific_guild_roles_dict['paired_roles']: for role_id in specific_guild_roles_dict['paired_roles']: if not bool([item for item in specific_guild.roles if (str(item.id) == role_id)]): specific_guild_removed_role_ids.append(role_id) else: try: specific_guild.get_role(int(role_id)) except: continue else: if specific_guild_roles_dict['paired_roles'][role_id]: if summary['response']['players'][0]['gameid'] in specific_guild_roles_dict['paired_roles'][role_id]['app_ids']: specific_guild_pinged_roles = specific_guild_pinged_roles + '<@&' + str(role_id) + '> ' elif not specific_guild_roles_dict['paired_roles'][role_id]['app_ids']: specific_guild_pinged_roles = specific_guild_pinged_roles + '<@&' + str(role_id) + '> ' if specific_guild_removed_role_ids: for role_id in specific_guild_removed_role_ids: del specific_guild_roles_dict['paired_roles'][role_id] for key in specific_guild_roles_dict['paired_roles']: for role_appid in specific_guild_roles_dict['paired_roles'][str(key)]['app_ids']: payload = {'appids': role_appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[role_appid]['data'] except KeyError: specific_guild_removed_store_urls_roles.append(role_appid) pass for key in specific_guild_roles_dict['paired_roles']: if specific_guild_removed_store_urls_roles: for role_appid in specific_guild_removed_store_urls_roles: try: specific_guild_roles_dict['paired_roles'][str(key)]['app_ids'].remove(role_appid) except ValueError: pass if len(specific_guild_roles_dict['paired_roles'][str(key)]['app_ids']) < 1: specific_guild_roles_dict['paired_roles'][str(key)]['app_ids'] = '' cloned_msg = '' sent_clone = False try: channel = client.get_channel(int(pair)) if (len(recent_posts) < 2) and (bool(specific_guild_pinged_roles)): cloned_msg = await channel.send(content=specific_guild_pinged_roles, embed=new_embed, components=clone_buttons) else: cloned_msg = await channel.send(embed=new_embed, components=clone_buttons) sent_clone = True except: pass if sent_clone: sql = "SELECT * FROM posts WHERE message_id = %s" val = (lfg_post.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() clone_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(clone_dict) except: pass clones[pair] = str(cloned_msg.id) sql = "UPDATE posts SET clones = %s WHERE message_id = %s" val = (str(clones), lfg_post.id) await mysql_commit(sql=sql, val=val) else: msg_register = Embed(title='❌┃Steam Profile No Longer Valid', description='We apologize however upon querying your profile we returned no results.', color=clr_error) msg_register.add_field(name='❔┃Why this Occured', value='In order to pull currently launched game and lobby information, your Steam Profile must not be deleted or too private.\n\nIf you have recently switched to a new Profile you must re-run `/register` in order to link said Profile to your discord.\n\nIf your Profile still is valid, consider opening your Profile\'s visiblity to help our query and making sure the Profile is complete.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_register, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile not Registered', description='We apologize however in order to use `/host` you must first register a Steam Profile using `/register`.', color=clr_error) msg_register.add_field(name='❔┃Why this is Necessary', value='In order to pull currently launched game and lobby information, we must first associate your account with a Steam Profile.\n\nOnce you register, everytime after whenever using `/host` we can automatically pull information such as a Lobby join link or Server IP.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_register, ephemeral=True) else: msg_type = Embed(title='❌┃Forbidden Channel Type', description='We apologize however in order to use `/host` you must be in a Text Channel, not a `' + str(inter.channel.type) + '` channel.', color=clr_error) msg_type.add_field(name='❔┃Why this is Necessary', value='Channels such as Threads are temporary, meant to be automatically locked or deleted over time and, you cannot make a Thread within a Thread.\n\nText Channels however do not auto-expire and have the ability to create private Threads for your LFG Requests!', inline=False) msg_type.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_type.set_thumbnail(url=img_error) msg_type.timestamp = datetime.datetime.now() msg_type.set_footer(text=txt_error + str(msg_type.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_type.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_type.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_type, ephemeral=True) else: msg_host = Embed(title='❌┃Command Disabled', description='We apologize however usage of `/host` is currently disabled by server admins. Please instead use `/link` which will generate a join link, game permitting.', color=clr_error) msg_host.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_host.set_thumbnail(url=img_error) msg_host.timestamp = datetime.datetime.now() msg_host.set_footer(text=txt_error + str(msg_host.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_host.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_host.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_host, ephemeral=True) # ################ Link ######################## @slash.slash_command(name='link', description='Whilst with a Steam game launched, use this command to generate a Lobby Join Link!', options=sopt_link) async def link(inter, password: str = ''): try: inter.guild.id except AttributeError: await inter.send(embed=msg_private, ephemeral=True) pass else: await inter.send(embed=msg_process, ephemeral=True, type=5) sql = "SELECT * FROM profiles WHERE discord_id = %s AND steam_id IS NOT NULL" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() if ids: password_lobby = False code = SteamID(int(ids[0]['steam_id'])) summary = apiauth.ISteamUser.GetPlayerSummaries(steamids=code) if summary['response']['players']: try: appid = summary['response']['players'][0]['gameid'] except KeyError: msg_error_game = Embed(title='🛑┃No Steam Game Launched', description='We apologize however in order to use `/link` you must first launch your game of choice to LFG for.\n\nPlease ensure it is not a Non-Steam manually added Game launched.', color=clr_error) msg_error_game.add_field(name='❔┃Why this is Required', value='In order to build your LFG Post we query the Steam API to pull information regarding your currently launched game.\n\nThis makes it so our service can support any title on Steam, all without you having to type what specific game to LFG for.\n\nWithout a game currently launched and the ability to read your recently played games we cannot determine what game you intend to LFG for.', inline=False) msg_error_game.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_game.set_thumbnail(url=img_error) msg_error_game.timestamp = datetime.datetime.now() msg_error_game.set_image(url='https://media1.giphy.com/media/WuaxwLWrJQNPLHN3n9/giphy.gif?cid=ecf05e47sz5rg1r365interrq729z3p4txnydpaji95r1uohwz&rid=giphy.gif&ct=g') msg_error_game.set_footer(text=txt_error + str(msg_error_game.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error_game, ephemeral=True) pass else: payload = {'key': os.environ['API_AUTH'], 'steamid': ids[0]['steam_id'], 'count': '100'} response_games = requests.get('https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/', params=payload) try: response_games.json()['response']['games'] except KeyError: msg_error_profile = Embed(title='🛑┃Steam Profile NOT Fully Public', description='We apologize however in order to use `/link` you must **have certain Profile settings public.** See the below steps on **opening your Profile\'s Privacy settings to Public.**', color=clr_error) msg_error_profile.add_field(name='❕┃You MUST Set Steam Profile to Public', value='**Only public profiles can use `/link`**, please use the following steps to set required settings to Public visibility:\n\n• **Step 1:** [Visit ' + summary['response']['players'][0]['personaname'] + '\'s Settings](' + url_redirect + 'steam://openurl/' + summary['response']['players'][0]['profileurl'] + 'edit/settings)\n• **Step 2:** Change `My profile` to **Public**\n• **Step 3:** Change `Game details` to **Public**\n• **Step 4:** Change `Game details` sub-option checkbox `Always keep my total playtime private even if users can see my game details.` to be **Un-Checked**\n\nAfter all steps completed, you can **immediately** begin using `/link` without issue!', inline=False) msg_error_profile.add_field(name='❔┃Why this is Required', value='In order to build your LFG Post we query the Steam API to pull information regarding your currently launched game.\n\nThis makes it so our service can support any title on Steam, all without you having to type what specific game to LFG for.\n\nWithout a game currently launched and the ability to read your recently played games we cannot determine what game you intend to LFG for.', inline=False) msg_error_profile.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_profile.set_thumbnail(url=img_error) msg_error_profile.timestamp = datetime.datetime.now() msg_error_profile.set_image(url='https://media1.giphy.com/media/1gdie7opvzRZv1yy9n/giphy.gif?cid=ecf05e47d2g2vc9zgnadadykbm9emn39xthu068jhlubrkac&rid=giphy.gif&ct=g') msg_error_profile.set_footer(text=txt_error + str(msg_error_profile.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error_profile, ephemeral=True) pass else: join_link = '' profile_link = url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid'] try: serverip = summary['response']['players'][0]['gameserverip'] except KeyError: try: lobbyid = summary['response']['players'][0]['lobbysteamid'] except KeyError: # No Join Link pass else: join_link = url_redirect + 'steam://joinlobby/' + appid + '/' + lobbyid if password: password_lobby = True pass else: if password: join_link = url_redirect + 'steam://connect/' + serverip + '/' + password[:500] else: join_link = url_redirect + 'steam://connect/' + serverip msg_post_color = random.randint(0, 0xffffff) msg_post = Embed(title='<:lfg:902430116402044949>┃LFG Links', description='See below your generated LFG links!', color=msg_post_color) msg_post.timestamp = datetime.datetime.now() footer_note = 'Posted' try: serverip = summary['response']['players'][0]['gameserverip'] except KeyError: try: lobbyid = summary['response']['players'][0]['lobbysteamid'] except KeyError: pass else: if appid == '813780': found_match = False apicheck_start = datetime.datetime.now() while True: for match in aoe2_apiauth.get_open_lobbies('aoe2de', True): if (lobbyid == match['lobby_id']) or (any(player['steam_id'] == summary['response']['players'][0]['steamid'] for player in match['players'])): join_link = url_redirect + 'aoe2de://0/' + match['match_id'] footer_note = footer_note + ' • Lobby ID: ' + 'aoe2de://0/' + match['match_id'] found_match = True break if (datetime.datetime.now() > apicheck_start + timedelta(seconds=10)) | found_match: break if not found_match: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) else: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) pass else: footer_note = 'Server IP: ' + str(serverip) msg_post.set_footer(text=footer_note + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_post.set_thumbnail(url=apiauth.ISteamUser.GetPlayerSummaries(steamids=int(ids[0]['steam_id']))['response']['players'][0]['avatarfull'] + '?uuid=' + str(inter.author.id)) except KeyError: try: msg_post.set_thumbnail(url=inter.author.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass pass app_name = summary['response']['players'][0]['gameextrainfo'] try: avatar = summary['response']['players'][0]['avatarfull'] except KeyError: try: msg_post.set_thumbnail(url=inter.author.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass else: msg_post.set_thumbnail(url=avatar + '?uuid=' + str(inter.author.id)) app_icon = img_unknown for idx, values in enumerate(response_games.json()['response']['games']): if str(response_games.json()['response']['games'][idx]['appid']) == appid: app_icon = 'http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/' + appid + '/' + response_games.json()['response']['games'][idx]['img_icon_url'] + '.jpg' if not app_icon: app_icon = img_unknown msg_post.set_author(name=app_name + ' - LFG', url=url_redirect + 'steam://url/StoreAppPage/' + appid + '/', icon_url=app_icon) break if join_link: if password_lobby: msg_post.add_field(name='Lobby Join Link', value='Automatically launches a user\'s game into your Lobby!\n• [**🕹️┃Right-Click or Long Press, to Copy Link**](' + join_link + ')' + '\n\n> **Note:** Passwords are not applicable for Steam Lobbies which use Join Links. Only applicable for Game Servers you can connect via IP from which we generate Connect Links for.', inline=False) else: msg_post.add_field(name='Lobby Join Link', value='Automatically launches a user\'s game into your Lobby!\n• [**🕹️┃Right-Click or Long Press, to Copy Link**](' + join_link + ')', inline=False) msg_post.add_field(name='Add as Friend Link', value='Automatically makes people add you as a friend on Steam!\n• [**👥┃Right-Click or Long Press, to Copy Link**](' + profile_link + ')', inline=False) else: msg_post.add_field(name='❌┃Lobby Join Link', value='**Unable to generate Lobby Join Link, see below tips:**\n• Join a starting or in-progress multiplayer Lobby/Server.\n• Only have your desired game running, nothing else open.\n• If all the above fail, your game **doesn\'t** support joining via Steam.', inline=False) msg_post.add_field(name='Add as Friend Link', value='Automatically makes people add you as a friend on Steam!\n• [**👥┃Right-Click or Long Press, to Copy Link**](' + profile_link + ')', inline=False) await inter.followup(embed=msg_post, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile No Longer Valid', description='We apologize however upon querying your profile we returned no results.', color=clr_error) msg_register.add_field(name='❔┃Why this Occured', value='In order to pull currently launched game and lobby information, your Steam Profile must not be deleted or too private.\n\nIf you have recently switched to a new Profile you must re-run `/register` in order to link said Profile to your discord.\n\nIf your Profile still is valid, consider opening your Profile\'s visiblity to help our query and making sure the Profile is complete.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_register, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile not Registered', description='We apologize however in order to use `/link` you must first register a Steam Profile using `/register`.', color=clr_error) msg_register.add_field(name='❔┃Why this is Necessary', value='In order to pull currently launched game and lobby information, we must first associate your account with a Steam Profile.\n\nOnce you register, everytime after whenever using `/link` we can automatically pull information such as a Lobby join link or Server IP.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_register, ephemeral=True) # ################ Modify ######################## @slash.slash_command(name='modify', description='Used to modify the parameters of an already active LFG Post!', options=sopt_modify) async def modify(inter, post_id: str, description: str = '', rules: str = '', password: str = '', banner: str = '', date: str = ''): try: inter.guild.id except AttributeError: await inter.send(embed=msg_private, ephemeral=True) pass else: await inter.send(embed=msg_process, ephemeral=True, type=5) if (description == '') & (rules == '') & (password == '') & (banner == '') & (date == ''): msg_params = Embed(title='❌┃Modify Parameters not Provided', description='We apologize however in order to use `/modify` you must provide either a new Description, Rules, Password, Banner, or Date.', color=clr_error) msg_params.add_field(name='❔┃Why this is Necessary', value='In order to modify posts we must be given a field in which to make changes to, providing no parameters means no changes occur.', inline=False) msg_params.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_params.set_thumbnail(url=img_error) msg_params.timestamp = datetime.datetime.now() msg_params.set_footer(text=txt_error + str(msg_params.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_params.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_params.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_params, ephemeral=True) else: msg_confirmation = Embed(title='<:lfg:902430116402044949>┃Submitted Details', description='See below the details of your submission using `/modify`.', color=0xffffff) if post_id: msg_confirmation.add_field(name='Post ID:', value=post_id, inline=False) if bool(description) & (len(description) <= 1024): description = str(pfilter.censor(description.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Description:', value=description, inline=False) elif bool(description) & (len(description) > 1024): description = txt_long msg_confirmation.add_field(name='Description:', value=description, inline=False) if bool(rules) & (len(rules) <= 1024): rules = str(pfilter.censor(rules.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Rules:', value=rules, inline=False) elif bool(rules) & (len(rules) > 1024): rules = txt_long msg_confirmation.add_field(name='Rules:', value=rules, inline=False) if bool(password) & (len(password) <= 1024): password = str(pfilter.censor(password.replace(r'\n', '\n'))) msg_confirmation.add_field(name='Password:', value=password, inline=False) elif bool(password) & (len(password) > 1024): password = txt_long msg_confirmation.add_field(name='Password:', value=password, inline=False) if bool(banner) & (len(banner) <= 1024): if validators.url(banner): msg_confirmation.add_field(name='Banner:', value=banner, inline=False) else: msg_confirmation.add_field(name='Banner:', value='Inputted banner url not a valid URL.', inline=False) elif bool(banner) & (len(banner) > 1024): msg_confirmation.add_field(name='Banner:', value='Inputted banner url more then 1024 characters.', inline=False) msg_confirmation.timestamp = datetime.datetime.now() msg_confirmation.set_footer(text=txt_footer + str(msg_confirmation.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirmation.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_confirmation.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass post = '' if post_id.isdecimal(): for guild_channel in client.get_all_channels(): if str(guild_channel.type) == 'text': try: await guild_channel.fetch_message(int(post_id)) except: continue else: post = await guild_channel.fetch_message(int(post_id)) break if (not post_id.isdecimal()) or (post is None): msg_ids = Embed(title='❌┃Invalid Post ID', description='We apologize however the Post ID you provided in order to use `/modify` did not return an existing LFG Post, ensure to only include numbers, no letters or symbols.', color=clr_error) msg_ids.add_field(name='❔┃Why this is Necessary', value='In order to modify posts we must be given a Post ID so we can find the message in which to make changes to, providing an invalid ID will not lead to changes.', inline=False) msg_ids.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_ids.set_thumbnail(url=img_error) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_error + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_ids, ephemeral=True) else: msg_ids = Embed(title='❌┃Not Owned LFG Post', description='We apologize however the Post ID you provided in order to use `/modify` did not return an actual LFG Post message belonging to you, ensure to only provide the ID of LFG Posts messages you are listed as Requestor of.', color=clr_error) msg_ids.add_field(name='❔┃Why this is Necessary', value='In order to modify posts we must be given a Post ID so we can find the message in which to make changes to, providing an ID of a post which you are not requestor of is forbidden.', inline=False) msg_ids.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_ids.set_thumbnail(url=img_error) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_error + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: post.embeds except: await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_ids, ephemeral=True) pass else: if post.embeds: if (post.author == client.user) & (post.embeds[0].title == '<:lfg:902430116402044949>┃LFG Requestor') & (post.embeds[0].thumbnail.url.split('?uuid=')[1] == str(inter.author.id)): if bool(description) & (description != txt_long): post.embeds[0].set_field_at(0, name="Description:", value=description, inline=False) if bool(rules) & (rules != txt_long): if bool([item for item in post.embeds[0].fields if item.name == 'Rules:']): for idx, field in enumerate(post.embeds[0].fields): if field.name == 'Rules:': post.embeds[0].set_field_at(idx, name="Rules:", value=rules, inline=False) break else: post.embeds[0].insert_field_at(1, name="Rules:", value=rules, inline=False) if bool(password) & (password != txt_long): if bool([item for item in post.embeds[0].fields if item.name == 'Password:']): for idx, field in enumerate(post.embeds[0].fields): if field.name == 'Password:': post.embeds[0].set_field_at(idx, name="Password:", value=password, inline=False) break else: post.embeds[0].insert_field_at(1, name="Password:", value=password, inline=False) if banner: if len(banner) < 1024: if validators.url(banner): post.embeds[0].set_image(url=banner) await inter.followup(embed=msg_confirmation, ephemeral=True) clone_row = ActionRow() for button in post.components[0].to_dict()['components']: if button['style'] == 5: clone_row.add_button(style=ButtonStyle.link, label=button['label'], emoji=button['emoji']['name'], url=button['url']) else: clone_row.add_button(style=ButtonStyle.secondary, label=button['label'], emoji=button['emoji']['name'], custom_id=button['custom_id']) try: await post.edit(embed=post.embeds[0], components=[clone_row]) except: pass sql = "SELECT * FROM posts WHERE message_id = %s" val = (post.id,) await mysql_commit(sql=sql, val=val) clones = {} try: sql_dict = sql_connect.fetchall()[0]['clones'] clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: global_embed = post.embeds[0] global_embed.description = clone_post.embeds[0].description global_embed.set_author(name=post.embeds[0].author.name.replace('- LFG', '- Global LFG'), url=post.embeds[0].author.url, icon_url=post.embeds[0].author.icon_url) global_embed.title = '<:logo:908953639085821973>┃LFG Requestor' post_host = await client.fetch_user(int(post.embeds[0].thumbnail.url.split('?uuid=')[1])) if post_host not in channel.guild.members: global_embed.description = '<@' + str(post_host.id) + '> aka `' + str(post_host) + '`' if str(inter.guild.id) == str(clone_post.guild.id): global_embed.set_footer(text='Direct Message on Discord and Add the Host on Steam!\n' + post.embeds[0].footer.text.split('\n')[1].strip(), icon_url=post.embeds[0].footer.icon_url) else: global_embed.set_footer(text='This is an external LFG Post, Add the Host on Steam!\n' + post.embeds[0].footer.text.split('\n')[1].strip(), icon_url=post.embeds[0].footer.icon_url) try: clone_row = ActionRow() for button in clone_post.components[0].to_dict()['components']: if button['style'] == 5: clone_row.add_button(style=ButtonStyle.link, label=button['label'], emoji=button['emoji']['name'], url=button['url']) else: clone_row.add_button(style=ButtonStyle.secondary, label=button['label'], emoji=button['emoji']['name'], custom_id=button['custom_id']) await clone_post.edit(embed=global_embed, components=[clone_row]) except: continue else: await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_ids, ephemeral=True) else: await inter.followup(embed=msg_confirmation, ephemeral=True) await inter.followup(embed=msg_ids, ephemeral=True) # ################ Search ######################## @slash.slash_command(name='search', description='Used to browse the Global LFG Network of Posts from other Servers!', options=sopt_search) async def search(inter, game_steam_url: str, keywords: str = '', rules: str = '', password: str = ''): await inter.send(embed=msg_process, ephemeral=True, type=5) game_steam_url = game_steam_url.split()[0] parameters = '• **Steam URL:** ' + game_steam_url if bool(keywords) or bool(rules) or bool(password): if keywords: parameters = parameters + '\n• **Keywords:** ' + keywords if rules: parameters = parameters + '\n• **Rules:** Required <:check:902430116234285136>' if password: parameters = parameters + '\n• **Password:** Required <:check:902430116234285136>' if bool((validators.url(game_steam_url))) & ('https://store.steampowered.com/app/'.lower() in game_steam_url.lower()): appid = (game_steam_url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: msg_ids = Embed(title='❌┃Invalid Steam URL', description='We apologize however the URL you provided in order to use `/search` did not return a exisitng Game of the Steam Store. Please check your source and attempt to re-visit the game on Steam.', color=clr_error) msg_ids.add_field(name='❔┃Why this is Necessary', value='In order to search for LFG posts we must be given a game Steam Store Page URL so we can find active LFG Posts which are for said game on the Global Network.', inline=False) msg_ids.add_field(name='<:discord:902408218138005575>┃Provided Parameters', value=parameters, inline=False) msg_ids.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_ids.set_thumbnail(url=img_error) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_error + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_ids, ephemeral=True) pass else: sql_connect.execute("SELECT * FROM posts") posts_checked = sql_connect.fetchall() posts_remove = [] for post in posts_checked: try: channel = client.get_channel(int(post['channel_id'])) post = await channel.fetch_message(int(post['message_id'])) except: posts_remove.append(post['message_id']) continue if posts_remove: for post in posts_remove: sql = "SELECT * FROM posts WHERE message_id = %s" val = (post,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (post,) await mysql_commit(sql=sql, val=val) for matching_post in posts_checked: time_limit = matching_post['post_time'] + timedelta(minutes=90) if datetime.datetime.now() >= time_limit: sql = "SELECT * FROM posts WHERE message_id = %s" val = (matching_post['message_id'],) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (matching_post['message_id'],) await mysql_commit(sql=sql, val=val) sql = "SELECT * FROM posts WHERE app_id = %s" val = (appid,) await mysql_commit(sql=sql, val=val) posts = sql_connect.fetchall() post_to_be_removed = [] if posts: for post in posts: if post['discord_id'] == str(inter.author.id): post_to_be_removed.append(post) if post_to_be_removed: for post in post_to_be_removed: posts.remove(post) post_to_be_removed = [] for post in posts: try: channel = client.get_channel(int(post['channel_id'])) post = await channel.fetch_message(int(post['message_id'])) except: post_to_be_removed.append(post) pass if post_to_be_removed: for post in post_to_be_removed: sql = "SELECT * FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) posts.remove(post) if posts: post_limit = 0 for idx, post in enumerate(posts): check_failed = False if post_limit <= 10: try: channel = client.get_channel(int(post['channel_id'])) post = await channel.fetch_message(int(post['message_id'])) except: sql = "SELECT * FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (post['message_id'],) await mysql_commit(sql=sql, val=val) pass else: sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (post.guild.id,) await mysql_commit(sql=sql, val=val) invite_checks = sql_connect.fetchall() internal_invites = ast.literal_eval(invite_checks[0]['setup_options']) if invite_checks[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite(str(invite_checks[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(post.guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), post.guild.id) await mysql_commit(sql=sql, val=val) except: pass pass sql = "SELECT global_lfg_invite FROM guilds WHERE guild_id = %s" val = (post.guild.id,) await mysql_commit(sql=sql, val=val) invite = sql_connect.fetchall() if bool(keywords) or bool(rules) or bool(password): if bool(keywords): post_prompt = '' for field in post.embeds[0].fields: if (field.name == 'Description:') | (field.name == 'Rules:'): post_prompt = post_prompt + field.value + ' ' if not all(word in post_prompt.casefold().split() for word in keywords.casefold().split()): check_failed = True if bool(rules) or bool(password): if bool(rules): if not bool([item for item in post.embeds[0].fields if item.name == 'Rules:']): check_failed = True if bool(password): if not bool([item for item in post.embeds[0].fields if item.name == 'Password:']): check_failed = True if not check_failed: components = str(post.components) urls = re.findall(r'(https?://[^\s]+)', components) if len(urls) > 1: if internal_invites['internal_invites'] == 'Enabled': post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=urls[0].replace("'", "")), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=urls[1].replace("'", "")), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=post.jump_url) )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=urls[0].replace("'", "")), Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=urls[1].replace("'", "")) )] else: if internal_invites['internal_invites'] == 'Enabled': post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=urls[0].replace("'", "")), Button(style=ButtonStyle.link, label="Join Discord", emoji='💻', url=invite[0]['global_lfg_invite']), Button(style=ButtonStyle.link, label="Message Link", emoji='🔗', url=post.jump_url) )] else: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=urls[0].replace("'", "")) )] post_limit = post_limit + 1 new_embed = post.embeds[0] try: inter.guild.id except AttributeError: pass else: post_host = await client.fetch_user(int(post.embeds[0].thumbnail.url.split('?uuid=')[1])) if post_host not in inter.guild.members: new_embed.description = '`' + str(post_host) + '`' await inter.followup(embed=new_embed, components=post_buttons, ephemeral=True) else: break if post_limit == 0: msg_ids = Embed(title='❕┃No Matching LFG Posts Found', description='Apologies, there are no active LFG Posts at this time for `' + response[appid]['data']['name'] + '` using the parameters you provided.\n\n**Note:** Use `/notify` to be informed of new LFG Posts for `' + response[appid]['data']['name'] + '`', color=0xffffff) msg_ids.add_field(name='<:discord:902408218138005575>┃Provided Parameters', value=parameters, inline=False) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_footer + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_ids, ephemeral=True) pass else: msg_ids = Embed(title='❕┃No LFG Posts Found', description='Apologies, there are no active LFG Posts at this time for `' + response[appid]['data']['name'] + '`\n\n**Note:** Use `/notify` to be informed of new LFG Posts for `' + response[appid]['data']['name'] + '`', color=0xffffff) msg_ids.add_field(name='<:discord:902408218138005575>┃Provided Parameters', value=parameters, inline=False) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_footer + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_ids, ephemeral=True) pass else: msg_ids = Embed(title='❌┃Invalid Steam URL', description='We apologize however the URL you provided in order to use `/search` did not return a exisitng Game of the Steam Store. Please check your source and attempt to re-visit the game on Steam.', color=clr_error) msg_ids.add_field(name='❔┃Why this is Necessary', value='In order to search for LFG posts we must be given a game Steam Store Page URL so we can find active LFG Posts which are for said game on the Global Network.', inline=False) msg_ids.add_field(name='<:discord:902408218138005575>┃Provided Parameters', value=parameters, inline=False) msg_ids.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_ids.set_thumbnail(url=img_error) msg_ids.timestamp = datetime.datetime.now() msg_ids.set_footer(text=txt_error + str(msg_ids.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_ids.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_ids.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_ids, ephemeral=True) pass # ################ Notify ######################## @slash.slash_command(name='notify', description='Used to setup Notifications for LFG Requests of specific Games!', options=sopt_notify) async def notify(inter, subscription: str = ''): await inter.send(embed=msg_process, ephemeral=True, type=5) if not subscription: sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) sql_prompt = sql_connect.fetchall() current_subscriptions = '' if sql_prompt: sql_prompt = ast.literal_eval(sql_prompt[0]['subscriptions']) if sql_prompt['app_ids']: current_subscriptions = current_subscriptions + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if current_subscriptions: current_subscriptions = current_subscriptions + '\n' current_subscriptions = current_subscriptions + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' current_subscriptions = current_subscriptions + '\n' + user_prompt msg_confirm = Embed(title='🔔┃LFG Notifications Setup', description='LFG Notifications inform you via Direct Message of a new LFG Post for desired Steam Game(s) and even corresponding Discord User(s)! Choose from below to either setup subscriptions or to clear all current subscriptions. \n\n**Note:** Remember to have Direct Messages from Server users enabled.', color=0xffffff) if current_subscriptions: if len('You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions) <= 1024: msg_confirm.add_field(name='<:lfg:902430116402044949>┃Current Notifications', value='You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, inline=False) else: await inter.followup(content='<:lfg:902430116402044949>┃Current Notifications\n\nYou currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, ephemeral=True) else: msg_confirm.add_field(name='<:lfg:902430116402044949>┃Current Notifications', value='You currently have no Notifications enabled for any Discord Users or Games.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_confirm, components=[ActionRow(sopt_notify_setup)], ephemeral=True) else: response_submitted = subscription[:1900].split() response_accepted = '' response_rejected = '' invalid_ids = [] invalid_urls = [] sql_prompt = {"app_ids": [], "paired_notifications": {}} for word in response_submitted: if ('<@' in word) & ('>' in word): word = word.replace('<@', '').replace('>', '').replace('!', '') if (word.isnumeric()) & (str(word) != str(inter.author.id)): try: await client.fetch_user(int(word)) except: if word not in invalid_ids: invalid_ids.append(word) pass else: if word not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][word] = [] elif ';' in word: if len(word.split(";", 1)) >= 2 and word.split(";", 1)[1]: pair = word.split(';') if (pair[0].isnumeric()) & (str(pair[0]) != str(inter.author.id)): try: await client.fetch_user(int(pair[0])) except: if pair[0] not in invalid_ids: invalid_ids.append(pair[0]) pass else: if pair[0] not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][pair[0]] = [] sub_pair = pair[1].split(',') for url in sub_pair: if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response: if response[appid]['success']: if appid not in sql_prompt["paired_notifications"][pair[0]]: sql_prompt["paired_notifications"][pair[0]].append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if url not in invalid_urls: invalid_urls.append(str(url)) else: if word + ' - You cannot use your own ID!' not in invalid_ids: invalid_ids.append(word + ' - You cannot use your own ID!') else: pair = word.replace(';', '') if (pair.isnumeric()) & (str(pair) != str(inter.author.id)): try: await client.fetch_user(int(pair)) except: if pair not in invalid_ids: invalid_ids.append(pair) pass else: if pair not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][pair] = "" else: if word not in invalid_ids: invalid_ids.append(word) elif bool((validators.url(word))) & ('https://store.steampowered.com/app/'.lower() in word.lower()): appid = (word.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response: if response[appid]['success']: if appid not in sql_prompt["app_ids"]: sql_prompt["app_ids"].append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if str(word) == str(inter.author.id): invalid_ids.append(word + ' - You cannot use your own ID!') elif word not in invalid_urls: invalid_urls.append(word) if invalid_ids: response_rejected = response_rejected + '**Rejected IDs:**\n' for uuid in invalid_ids: if uuid is not invalid_ids[-1]: response_rejected = response_rejected + '• `' + uuid + '`\n' else: response_rejected = response_rejected + '• `' + uuid + '`\n\n' if invalid_urls: response_rejected = response_rejected + '**Rejected URLs:**\n' for url in invalid_urls: if url is not invalid_urls[-1]: response_rejected = response_rejected + '• `' + url + '`\n' else: response_rejected = response_rejected + '• `' + url + '`\n' if sql_prompt != {"app_ids": [], "paired_notifications": {}}: sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() if ids: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sql_prompt), inter.author.id) await mysql_commit(sql=sql, val=val) else: sql = "INSERT INTO notifications (discord_id, subscriptions) VALUES (%s, %s)" val = (inter.author.id, str(sql_prompt)) await mysql_commit(sql=sql, val=val) if sql_prompt['app_ids']: response_accepted = response_accepted + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: response_accepted = response_accepted + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: response_accepted = response_accepted + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if response_accepted: response_accepted = response_accepted + '\n' response_accepted = response_accepted + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' response_accepted = response_accepted + '\n' + user_prompt msg_confirm = Embed(title='🔔┃LFG Notifications Updated', description='Thank you for providing your desired notification parameters, see below confirmation of accepted and rejected items.\n\n**Note:** Re-run `/notify` to update LFG Notification preferences in the future!', color=0xffffff) if len('The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted) <= 1024: msg_confirm.add_field(name='<:check:902430116234285136>┃Accepted Parameters', value='The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted, inline=False) else: await inter.followup(content='<:check:902430116234285136>┃Accepted Parameters\n\n' + 'The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted, ephemeral=True) if bool(response_rejected) & (len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) <= 1024): msg_confirm.add_field(name='❌┃Rejected Parameters', value='The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, inline=False) elif bool(response_rejected) & (len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) > 1024): await inter.followup(content='❌┃Rejected Parameters\n\n' + 'The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, ephemeral=True) msg_confirm.add_field(name='❔┃Troubleshooting Tips', value='• In order to access a user\'s Discord ID, follow this [Official Guide](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)\n• In order to access a Steam Store URL from within the Steam Client, follow this [Community Guide](https://support-mabinogi.nexon.net/hc/en-us/articles/115004524623-How-do-I-find-my-Steam-ID-) on enabling URLs within the Client.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_confirm, ephemeral=True) else: msg_confirm = Embed(title='❗┃LFG Notifications Not Updated', description='Please be aware all provided notification parameters were rejected as not valid Discord User IDs or Steam Store URLs. Please re-run `/notify` to update LFG Notification preferences with corrected parameters.', color=clr_error) if len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) <= 1024: msg_confirm.add_field(name='❌┃Rejected Parameters', value='The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, inline=False) else: await inter.followup(content='❌┃Rejected Parameters\n\n' + 'The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, ephemeral=True) msg_confirm.add_field(name='❔┃Troubleshooting Tips', value='• In order to access a user\'s Discord ID, follow this [Official Guide](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)\n• In order to access a Steam Store URL from within the Steam Client, follow this [Community Guide](https://support-mabinogi.nexon.net/hc/en-us/articles/115004524623-How-do-I-find-my-Steam-ID-) on enabling URLs within the Client.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_confirm.set_thumbnail(url=img_error) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_confirm, ephemeral=True) # ################ Context Notify ######################## @slash.user_command(name="🔔┃Subscribe") async def subscribe(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) hostid = str(inter.user.id) user_id = inter.author.id if str(hostid) != str(user_id): sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) current_subs = sql_connect.fetchall() already_subbed = False if current_subs: sub_dict = ast.literal_eval(current_subs[0]['subscriptions']) if str(hostid) in sub_dict['paired_notifications'].keys(): already_subbed = True del sub_dict['paired_notifications'][hostid] else: sub_dict['paired_notifications'][hostid] = [] if sub_dict['paired_notifications'] != {}: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) else: sql = "DELETE FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) else: sql = "INSERT INTO notifications (discord_id, subscriptions) VALUES (%s, %s)" val = (user_id, str({"app_ids": [], "paired_notifications": {str(hostid): []}})) await mysql_commit(sql=sql, val=val) msg_subscription = Embed(title='<:lfg:902430116402044949>┃LFG Requestor', description='<@' + str(hostid) + '>', color=0xffffff) if already_subbed: msg_subscription.add_field(name='<:check:902430116234285136>┃Subscription Removed', value='You have succesfully **un-subscribed** to <@' + str(hostid) + '> for all Games!\n\nYou will no longer recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post.', inline=False) else: msg_subscription.add_field(name='<:check:902430116234285136>┃Subscription Added', value='You have succesfully **subscribed** to <@' + str(hostid) + '> for all Games!\n\nYou will now recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post for any game.', inline=False) sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) sql_prompt = sql_connect.fetchall() current_subscriptions = '' if sql_prompt: sql_prompt = ast.literal_eval(sql_prompt[0]['subscriptions']) if sql_prompt['app_ids']: current_subscriptions = current_subscriptions + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if current_subscriptions: current_subscriptions = current_subscriptions + '\n' current_subscriptions = current_subscriptions + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' current_subscriptions = current_subscriptions + '\n' + user_prompt if current_subscriptions: if len('You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions) <= 1024: msg_subscription.add_field(name='<:lfg:902430116402044949>┃Updated Notifications', value='You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, inline=False) else: await inter.followup(content='<:lfg:902430116402044949>┃Updated Notifications\n\nYou currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, ephemeral=True) else: msg_subscription.add_field(name='<:lfg:902430116402044949>┃Updated Notifications', value='You have no remaining Notifications for any Discord User(s) or Game(s). Run `/notify` to setup new Notifications!', inline=False) msg_subscription.timestamp = datetime.datetime.now() msg_subscription.set_footer(text=txt_footer + str(msg_subscription.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_subscription.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) await inter.followup(embed=msg_subscription, ephemeral=True) else: msg_subscription_error = Embed(title='❌┃Unable to Subscribe', description='You are unable to subscribe to yourself for notifications of new LFG Posts!', color=clr_error) msg_subscription_error.add_field(name='❔┃Setup Notifications', value='Press the `🔔` buttton on other people\'s posts to subscribe to them for said game, or consider running `/notify` for other notifications.', inline=False) msg_subscription_error.timestamp = datetime.datetime.now() msg_subscription_error.set_footer(text=txt_footer + str(msg_subscription_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_subscription_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_subscription_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_subscription_error, ephemeral=True) # ################ Karma ######################## @slash.slash_command(name='karma', description='Used to check the karma leaderboards of LFG hosts, Global and Server!', options=sopt_karma) async def karma(inter, user_id: str = ''): await inter.send(embed=msg_process, ephemeral=True, type=5) dm_channel = False try: inter.guild.id except AttributeError: dm_channel = True pass sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() sql_connect.execute("SELECT * FROM profiles") all_profiles = sql_connect.fetchall() server_profiles = {} global_profiles = {} global_leaderboard = 'No users have currently linked their Steam Profile to their Discord Account, thus no statistics can be pulled.' server_leaderboard = 'No users have currently linked their Steam Profile to their Discord Account, thus no statistics can be pulled.' msg_karma = Embed(title='👍🏼┃Karma Leaderbaords', description='Users who press `👍🏼` on LFG Posts give +1 Karma, a form of rating. This rating is useful for determing quality LFG Hosts when searching for your next game!', color=0xffffff) if all_profiles: for profile in all_profiles: try: global_user = await client.fetch_user(int(profile['discord_id'])) except: continue else: if not dm_channel: if global_user in inter.guild.members: server_profiles[int(profile['discord_id'])] = int(profile['karma']) global_profiles[int(profile['discord_id'])] = int(profile['karma']) if global_profiles: global_leaderboard = '' global_profiles_all = sorted(global_profiles.items(), key=lambda x: x[1], reverse=True) global_profiles_top = sorted(global_profiles.items(), key=lambda x: x[1], reverse=True)[:10] for idx, host in enumerate(global_profiles_top): global_user = await client.fetch_user(int(host[0])) if not dm_channel: if global_user in inter.guild.members: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, <@' + str(host[0]) + '>**\'s Karma:** `' + str(host[1]) + '`\n' else: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, `' + str(global_user) + '`**\'s Karma:** `' + str(host[1]) + '`\n' else: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, `' + str(global_user) + '`**\'s Karma:** `' + str(host[1]) + '`\n' if not dm_channel: if server_profiles: server_leaderboard = '' server_profiles_all = sorted(server_profiles.items(), key=lambda x: x[1], reverse=True) server_profiles_top = sorted(server_profiles.items(), key=lambda x: x[1], reverse=True)[:10] for idx, host in enumerate(server_profiles_top): server_leaderboard = server_leaderboard + '• **#' + str(int(idx) + 1) + '**, <@' + str(host[0]) + '>**\'s Karma:** `' + str(host[1]) + '`\n' if user_id: try: user_id = user_id.replace('<@', '').replace('>', '').replace('!', '') queried_user = await client.fetch_user(int(user_id)) except: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• Apologies however the Discord User you provided does not exist, try again.', inline=False) pass else: if int(user_id) in global_profiles.keys(): if int(user_id) != int(inter.author.id): queried_global_standing = '• **Global Standing:** `#' + str(global_profiles_all.index((int(user_id), int(global_profiles[int(user_id)]))) + 1) + '`' if not dm_channel: if queried_user in inter.guild.members: queried_global_standing = queried_global_standing + '\n• `' + str(inter.guild.name) + '` **Standing:** `#' + str(server_profiles_all.index((int(user_id), int(server_profiles[int(user_id)]))) + 1) + '`' msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value=queried_global_standing + '\n• <@' + str(user_id) + '>**\'s Karma:** `' + str(global_profiles[int(user_id)]) + '`', inline=False) else: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• You have queried yourself, see `👥 Personal Standings`', inline=False) else: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• User has yet to run `/register` to link their Steam Profile to Discord!', inline=False) msg_karma.add_field(name='<:logo:908953639085821973>┃Global Top 10 Hosts:', value=global_leaderboard, inline=False) if not dm_channel: msg_karma.add_field(name='<:discord:902408218138005575>┃Server Top 10 Hosts:', value=server_leaderboard, inline=False) if profile_prompt: if not dm_channel: msg_karma.add_field(name='👥┃Personal Standings', value='• **Global Standing:** `#' + str(global_profiles_all.index((int(inter.author.id), int(global_profiles[int(inter.author.id)]))) + 1) + '`\n•`' + str(inter.guild.name) + '` **Standing:** `#' + str(server_profiles_all.index((int(inter.author.id), int(server_profiles[int(inter.author.id)]))) + 1) + '`\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma.add_field(name='👥┃Personal Standings', value='• **Global Standing:** `#' + str(global_profiles_all.index((int(inter.author.id), int(global_profiles[int(inter.author.id)]))) + 1) + '`\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma.add_field(name='👥┃Personal Standings', value='• Please first run `/register` to link your Steam Profile to Discord!', inline=False) else: msg_karma.add_field(name='❌┃No Karma Standings', value='We apologize, however it seems nobody has linked their Steam Profiles to Discord yet!\n• Please run `/register` to link your Steam Profile to Discord to help!', inline=False) msg_karma.timestamp = datetime.datetime.now() msg_karma.set_footer(text=txt_footer + str(msg_karma.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: if not dm_channel: msg_karma.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) else: msg_karma.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) pass await inter.followup(embed=msg_karma, ephemeral=True) # ################ Announce ######################## @slash.slash_command(name='announce', description='Used to broadcast to all of your current LFG subscribers!', options=sopt_announce) async def karma(inter, announcement): await inter.send(embed=msg_process, ephemeral=True, type=5) sql = "SELECT * FROM profiles WHERE discord_id = %s AND steam_id IS NOT NULL" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() if profile_prompt: sql = "SELECT * FROM notifications WHERE LOCATE(%s, subscriptions) > 0" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) subscribed_users = sql_connect.fetchall() if subscribed_users: announcement = str(pfilter.censor(announcement.replace(r'\n', '\n'))) embed_message_announce = Embed(title='❕┃Subscriber Announcement', description='Please be aware Bot <@' + str(client.user.id) + '> has delivered an Announcement below from host `' + str(inter.author) + '` whom you are subscribed to:', color=0xffffff) if len(announcement) > 1018: embed_message_announce.add_field(name="Announcement:", value='See above the announcement provided...', inline=False) else: embed_message_announce.add_field(name="Announcement:", value=announcement, inline=False) embed_message_announce.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: embed_message_announce.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: embed_message_announce.set_author(name=inter.author.name, url=url_discord, icon_url=img_unknown) pass embed_message_announce.timestamp = datetime.datetime.now() embed_message_announce.set_footer(text=txt_footer + str(embed_message_announce.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) button_announcement = [ActionRow(Button(style=ButtonStyle.link, label="Add Host as Friend", emoji='👥', url=url_redirect + 'steam://friends/add/' + str(profile_prompt[0]['steam_id'])), Button(style=ButtonStyle.secondary, label='Un-Subscribe', emoji='🔕', custom_id='announce_unsub ' + str(inter.author.id)))] for subbed_user in subscribed_users: subbed_uuid = subbed_user['discord_id'] try: user = await client.fetch_user(int(subbed_uuid)) except: pass else: try: if len(announcement) > 1018: await user.send(content='❕┃**Subscriber Announcement:**\n' + announcement[:1900] + '...', embed=embed_message_announce, components=button_announcement) else: await user.send(embed=embed_message_announce, components=button_announcement) except: pass embed_message_host = Embed(title='❕┃Subscriber Announcement Delivered', description='Please be aware Bot <@' + str(client.user.id) + '> has delivered the requested announcement to your `' + str(len(subscribed_users)) + '` subscriber(s):', color=0xffffff) if len(announcement) > 1018: embed_message_host.add_field(name="Announcement:", value=announcement[:1018] + '...', inline=False) else: embed_message_host.add_field(name="❔┃What they will See", value='• Your above announcement formatted in an embed\n• `👥 Add Host as Friend` button so they may friend you on Steam\n• `🔕 Un-Subscribe` button to cease notifications', inline=False) embed_message_host.add_field(name="Announcement:", value=announcement, inline=False) embed_message_host.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_host.timestamp = datetime.datetime.now() embed_message_host.set_footer(text=txt_footer + str(embed_message_host.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await inter.followup(embed=embed_message_host, ephemeral=True) else: msg_null_subs = Embed(title='❌┃No Current Subscribers', description='We apologize however in order to use `/announce` you must first have a subscriber.', color=clr_error) msg_null_subs.add_field(name='❔┃Why this is Necessary', value='To gain subs instruct users to right click your name and choose `🔔┃Subscribe` from the Apps, then you can use `/announce` to broadcast to them!', inline=False) msg_null_subs.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_null_subs.set_thumbnail(url=img_error) msg_null_subs.timestamp = datetime.datetime.now() msg_null_subs.set_footer(text=txt_error + str(msg_null_subs.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_null_subs.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_null_subs.set_author(name=inter.author.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_null_subs, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile not Registered', description='We apologize however in order to use `/announce` you must first register a Steam Profile using `/register`.', color=clr_error) msg_register.add_field(name='❔┃Why this is Necessary', value='In order to pull currently launched game and lobby information, we must first associate your account with a Steam Profile.\n\nOnce you register, everytime after whenever using `/announce` we can automatically pull information such as a Add Host as Friend link.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_register.set_author(name=inter.author.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_register, ephemeral=True) # ################ Context Karma ######################## @slash.user_command(name="👥┃Check Karma") async def karma(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) user_id = str(inter.user.id) dm_channel = False try: inter.guild.id except AttributeError: dm_channel = True pass sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() sql_connect.execute("SELECT * FROM profiles") all_profiles = sql_connect.fetchall() server_profiles = {} global_profiles = {} global_leaderboard = 'No users have currently linked their Steam Profile to their Discord Account, thus no statistics can be pulled.' server_leaderboard = 'No users have currently linked their Steam Profile to their Discord Account, thus no statistics can be pulled.' msg_karma = Embed(title='👍🏼┃Karma Leaderbaords', description='Users who press `👍🏼` on LFG Posts give +1 Karma, a form of rating. This rating is useful for determing quality LFG Hosts when searching for your next game!', color=0xffffff) if all_profiles: for profile in all_profiles: try: global_user = await client.fetch_user(int(profile['discord_id'])) except: continue else: if not dm_channel: if global_user in inter.guild.members: server_profiles[int(profile['discord_id'])] = int(profile['karma']) global_profiles[int(profile['discord_id'])] = int(profile['karma']) if global_profiles: global_leaderboard = '' global_profiles_all = sorted(global_profiles.items(), key=lambda x: x[1], reverse=True) global_profiles_top = sorted(global_profiles.items(), key=lambda x: x[1], reverse=True)[:10] for idx, host in enumerate(global_profiles_top): global_user = await client.fetch_user(int(host[0])) if not dm_channel: if global_user in inter.guild.members: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, <@' + str(host[0]) + '>**\'s Karma:** `' + str(host[1]) + '`\n' else: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, `' + str(global_user) + '`**\'s Karma:** `' + str(host[1]) + '`\n' else: global_leaderboard = global_leaderboard + '• **#' + str(int(idx) + 1) + '**, `' + str(global_user) + '`**\'s Karma:** `' + str(host[1]) + '`\n' if not dm_channel: if server_profiles: server_leaderboard = '' server_profiles_all = sorted(server_profiles.items(), key=lambda x: x[1], reverse=True) server_profiles_top = sorted(server_profiles.items(), key=lambda x: x[1], reverse=True)[:10] for idx, host in enumerate(server_profiles_top): server_leaderboard = server_leaderboard + '• **#' + str(int(idx) + 1) + '**, <@' + str(host[0]) + '>**\'s Karma:** `' + str(host[1]) + '`\n' try: user_id = user_id.replace('<@', '').replace('>', '').replace('!', '') queried_user = await client.fetch_user(int(user_id)) except: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• Apologies however the Discord User you provided does not exist, try again.', inline=False) pass else: if int(user_id) in global_profiles.keys(): if int(user_id) != int(inter.author.id): queried_global_standing = '• **Global Standing:** `#' + str(global_profiles_all.index((int(user_id), int(global_profiles[int(user_id)]))) + 1) + '`' if not dm_channel: if queried_user in inter.guild.members: queried_global_standing = queried_global_standing + '\n• `' + str(inter.guild.name) + '` **Standing:** `#' + str(server_profiles_all.index((int(user_id), int(server_profiles[int(user_id)]))) + 1) + '`' msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value=queried_global_standing + '\n• <@' + str(user_id) + '>**\'s Karma:** `' + str(global_profiles[int(user_id)]) + '`', inline=False) else: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• You have queried yourself, see `👥 Personal Standings`', inline=False) else: msg_karma.add_field(name='<:check:902430116234285136>┃Queried User\'s Standings:', value='• User has yet to run `/register` to link their Steam Profile to Discord!', inline=False) msg_karma.add_field(name='<:logo:908953639085821973>┃Global Top 10 Hosts:', value=global_leaderboard, inline=False) if not dm_channel: msg_karma.add_field(name='<:discord:902408218138005575>┃Server Top 10 Hosts:', value=server_leaderboard, inline=False) if profile_prompt: if not dm_channel: msg_karma.add_field(name='👥┃Personal Standings', value='• **Global Standing:** `#' + str(global_profiles_all.index((int(inter.author.id), int(global_profiles[int(inter.author.id)]))) + 1) + '`\n•`' + str(inter.guild.name) + '` **Standing:** `#' + str(server_profiles_all.index((int(inter.author.id), int(server_profiles[int(inter.author.id)]))) + 1) + '`\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma.add_field(name='👥┃Personal Standings', value='• **Global Standing:** `#' + str(global_profiles_all.index((int(inter.author.id), int(global_profiles[int(inter.author.id)]))) + 1) + '`\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma.add_field(name='👥┃Personal Standings', value='• Please first run `/register` to link your Steam Profile to Discord!', inline=False) else: msg_karma.add_field(name='❌┃No Karma Standings', value='We apologize, however it seems nobody has linked their Steam Profiles to Discord yet!\n• Please run `/register` to link your Steam Profile to Discord to help!', inline=False) msg_karma.timestamp = datetime.datetime.now() msg_karma.set_footer(text=txt_footer + str(msg_karma.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: if not dm_channel: msg_karma.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) else: msg_karma.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) pass await inter.followup(embed=msg_karma, ephemeral=True) # ################ Context Links ######################## @slash.user_command(name="🎮┃Game Links") async def links(inter): try: inter.guild.id except AttributeError: await inter.send(embed=msg_private, ephemeral=True) pass else: await inter.send(embed=msg_process, ephemeral=True, type=5) sql = "SELECT * FROM profiles WHERE discord_id = %s AND steam_id IS NOT NULL" val = (inter.user.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() if ids: code = SteamID(int(ids[0]['steam_id'])) summary = apiauth.ISteamUser.GetPlayerSummaries(steamids=code) if summary['response']['players']: try: appid = summary['response']['players'][0]['gameid'] except KeyError: msg_error_game = Embed(title='🛑┃No Steam Game Launched', description='We apologize however <@' + str(inter.user.id) + '> does not have open any Steam game, thus no game links can be generated.', color=clr_error) msg_error_game.add_field(name='❔┃Why this is Required', value='In order to build game links we query the Steam API to pull information regarding a user\'s currently launched game.\n\nThis makes it so our service can support any title on Steam, all without you having to type what specific game to LFG for.\n\nWithout a game currently launched and the ability to read a user\'s recently played games we cannot determine what game a user intends to LFG for.', inline=False) msg_error_game.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_game.set_thumbnail(url=img_error) msg_error_game.timestamp = datetime.datetime.now() msg_error_game.set_image(url='https://media1.giphy.com/media/WuaxwLWrJQNPLHN3n9/giphy.gif?cid=ecf05e47sz5rg1r365interrq729z3p4txnydpaji95r1uohwz&rid=giphy.gif&ct=g') msg_error_game.set_footer(text=txt_error + str(msg_error_game.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_game.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error_game, ephemeral=True) pass else: payload = {'key': os.environ['API_AUTH'], 'steamid': ids[0]['steam_id'], 'count': '100'} response_games = requests.get('https://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v1/', params=payload) try: response_games.json()['response']['games'] except KeyError: msg_error_profile = Embed(title='🛑┃Steam Profile NOT Fully Public', description='We apologize however <@' + str(inter.user.id) + '> has restricted their Steam Profile\'s Privacy settings to prevent generating game links.', color=clr_error) msg_error_profile.add_field(name='❔┃Why this is Required', value='In order to build a user\'s LFG Post we query the Steam API to pull information regarding your currently launched game.\n\nThis makes it so our service can support any title on Steam, all without you having to type what specific game to LFG for.\n\nWithout a game currently launched and the ability to read a user\'s recently played games we cannot determine what game a user intends to LFG for.', inline=False) msg_error_profile.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error_profile.set_thumbnail(url=img_error) msg_error_profile.timestamp = datetime.datetime.now() msg_error_profile.set_image(url='https://media1.giphy.com/media/1gdie7opvzRZv1yy9n/giphy.gif?cid=ecf05e47d2g2vc9zgnadadykbm9emn39xthu068jhlubrkac&rid=giphy.gif&ct=g') msg_error_profile.set_footer(text=txt_error + str(msg_error_profile.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error_profile.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error_profile, ephemeral=True) pass else: join_link = '' profile_link = url_redirect + 'steam://friends/add/' + summary['response']['players'][0]['steamid'] try: serverip = summary['response']['players'][0]['gameserverip'] except KeyError: try: lobbyid = summary['response']['players'][0]['lobbysteamid'] except KeyError: # No Join Link pass else: join_link = url_redirect + 'steam://joinlobby/' + appid + '/' + lobbyid pass else: join_link = url_redirect + 'steam://connect/' + serverip msg_post_color = random.randint(0, 0xffffff) msg_post = Embed(title='<:lfg:902430116402044949>┃LFG Links', description='See below <@' + str(inter.user.id) + '>\'s generated Game links.\nClick to automatically launch through Steam!', color=msg_post_color) msg_post.timestamp = datetime.datetime.now() footer_note = 'Posted' try: serverip = summary['response']['players'][0]['gameserverip'] except KeyError: try: lobbyid = summary['response']['players'][0]['lobbysteamid'] except KeyError: pass else: if appid == '813780': found_match = False apicheck_start = datetime.datetime.now() while True: for match in aoe2_apiauth.get_open_lobbies('aoe2de', True): if (lobbyid == match['lobby_id']) or (any(player['steam_id'] == summary['response']['players'][0]['steamid'] for player in match['players'])): join_link = url_redirect + 'aoe2de://0/' + match['match_id'] footer_note = footer_note + ' • Lobby ID: ' + 'aoe2de://0/' + match['match_id'] found_match = True break if (datetime.datetime.now() > apicheck_start + timedelta(seconds=10)) | found_match: break if not found_match: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) else: footer_note = footer_note + ' • Lobby ID: ' + str(lobbyid) pass else: footer_note = 'Server IP: ' + str(serverip) msg_post.set_footer(text=footer_note + str(msg_post.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_post.set_thumbnail(url=apiauth.ISteamUser.GetPlayerSummaries(steamids=int(ids[0]['steam_id']))['response']['players'][0]['avatarfull'] + '?uuid=' + str(inter.author.id)) except KeyError: try: msg_post.set_thumbnail(url=inter.user.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass pass app_name = summary['response']['players'][0]['gameextrainfo'] try: avatar = summary['response']['players'][0]['avatarfull'] except KeyError: try: msg_post.set_thumbnail(url=inter.user.avatar.url + '?uuid=' + str(inter.author.id)) except AttributeError: msg_post.set_thumbnail(url=img_unknown + '?uuid=' + str(inter.author.id)) pass pass else: msg_post.set_thumbnail(url=avatar + '?uuid=' + str(inter.author.id)) app_icon = img_unknown for idx, values in enumerate(response_games.json()['response']['games']): if str(response_games.json()['response']['games'][idx]['appid']) == appid: app_icon = 'http://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/' + appid + '/' + response_games.json()['response']['games'][idx]['img_icon_url'] + '.jpg' if not app_icon: app_icon = img_unknown msg_post.set_author(name=app_name + ' - LFG', url=url_redirect + 'steam://url/StoreAppPage/' + appid + '/', icon_url=app_icon) break if join_link: post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Join Game", emoji='🕹️', url=join_link), Button(style=ButtonStyle.link, label="Add User as Friend", emoji='👥', url=profile_link) )] else: msg_post.add_field(name='❌┃Join Game Button', value='**Unable to generate Join Game Button, see below reasons:**\n• They may not be in starting or in-progress multiplayer Lobby/Server.\n• They may more than one game running which means their lobby information is hidden.\n• Their opened game may **not** support joining via Steam.', inline=False) post_buttons = [ActionRow( Button(style=ButtonStyle.link, label="Add User as Friend", emoji='👥', url=profile_link) )] await inter.followup(embed=msg_post, components=post_buttons, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile No Longer Valid', description='We apologize however <@' + str(inter.user.id) + '> has a invalid Steam Profile currently associated with their Discord, preventing generating game links.', color=clr_error) msg_register.add_field(name='❔┃Why this Occured', value='In order to pull currently launched game and lobby information, a user\'s Steam Profile must not be deleted or too private.\n\nIf they have recently switched to a new Profile they must re-run `/register` in order to link said Profile to their discord.\n\nIf their Profile still is valid, they may need to open their Profile\'s visiblity to help our query and making sure the Profile is complete.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_register, ephemeral=True) else: msg_register = Embed(title='❌┃Steam Profile not Registered', description='We apologize however <@' + str(inter.user.id) + '> has not yet run `/register` to associate a Steam Profile with their Discord.', color=clr_error) msg_register.add_field(name='❔┃Why this is Necessary', value='In order to pull currently launched game and lobby information, we must first associate their account with a Steam Profile.\n\nOnce they register, we can automatically pull information such as a Lobby join link or Server IP.', inline=False) msg_register.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_register.set_thumbnail(url=img_error) msg_register.timestamp = datetime.datetime.now() msg_register.set_footer(text=txt_error + str(msg_register.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_register.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_register, ephemeral=True) # ################ Context Karma ######################## @slash.user_command(name="❔┃Followers") async def followers(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) user_id = str(inter.user.id) dm_channel = False try: inter.guild.id except AttributeError: dm_channel = True pass sql = "SELECT * FROM notifications WHERE LOCATE(%s, subscriptions) > 0" val = (user_id,) await mysql_commit(sql=sql, val=val) subscribed_users = sql_connect.fetchall() deleted_users = [] followers_list = '' user_count = 0 if subscribed_users: for subbed_user in subscribed_users: subbed_uuid = subbed_user['discord_id'] try: user = await client.fetch_user(int(subbed_uuid)) except: deleted_users.append(subbed_uuid) pass else: user_count = user_count + 1 game_prompt = '' current_subs = ast.literal_eval(subbed_user['subscriptions']) if current_subs['paired_notifications'][user_id]: for game in current_subs['paired_notifications'][user_id]: guid = str(game) payload = {'appids': str(guid)} guid = str(game) response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not current_subs['paired_notifications'][user_id][-1]: game_prompt = game_prompt + '**[' + response[guid]['data']['name'] + '](https://store.steampowered.com/app/' + guid + '/)**, ' else: game_prompt = game_prompt + '**[' + response[guid]['data']['name'] + '](https://store.steampowered.com/app/' + guid + '/)**' if not game_prompt: game_prompt = '**Any Game**' if dm_channel: followers_list = followers_list + '**' + str(user_count) + '.** `' + str(user) + '`: ' + game_prompt + '\n' else: if user in inter.guild.members: followers_list = followers_list + '**' + str(user_count) + '.** <@' + str(subbed_uuid) + '>' + ': ' + game_prompt + '\n' else: followers_list = followers_list + '**' + str(user_count) + '.** `' + str(user) + '`: ' + game_prompt + '\n' if deleted_users: for invalid_uuid in deleted_users: sql = "DELETE FROM notifications WHERE discord_id = %s" val = (invalid_uuid,) await mysql_commit(sql=sql, val=val) sql = "SELECT * FROM notifications WHERE LOCATE(%s, subscriptions) > 0" val = (user_id,) await mysql_commit(sql=sql, val=val) subscribed_users = sql_connect.fetchall() if subscribed_users: if str(inter.author.id) != user_id: msg_followers = Embed(title='🔔┃Subscribed Followers', description='<@' + str(user_id) + '> currently has **`' + str(len(subscribed_users)) + '`** followers for **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** usage.', color=0xffffff) else: msg_followers = Embed(title='🔔┃Subscribed Followers', description='**You** currently have **`' + str(len(subscribed_users)) + '`** followers for **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** usage.', color=0xffffff) if len(followers_list) <= 1024: msg_followers.add_field(name='👥┃Followers List', value=followers_list, inline=False) else: if str(inter.author.id) != user_id: msg_followers = Embed(title='🔔┃Subscribed Followers', description='<@' + str(user_id) + '> currently has **no** followers subscribed for notifications on **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** usage.', color=0xffffff) msg_followers.add_field(name='❔┃What You Can Do', value='**See below to be alerted when a host creates a new LFG post:**\n\n• If you right-click a host\'s profile name, it will subscribe you for notifications of all their hosted games.\n• For specific subscriptions, run **[`/notify`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/notify)** providing the host\'s ID.\n• You may also subscribe by clicking the `🔔` icon on any LFG post they create using **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)**', inline=False) else: msg_followers = Embed(title='🔔┃Subscribed Followers', description='**You** currently have **no** followers subscribed for notifications on **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)** usage.', color=0xffffff) msg_followers.add_field(name='❔┃What You Can Do', value='**It is wise to grow a following, as to ensure more people are aware whenever you host!**\n\n• If users right-click your profile name, they will subscribe to you for all hosted games.\n• For specific subscriptions, have them run **[`/notify`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/notify)** providing your user ID.\n• Users may also subscribe by clicking the `🔔` icon on any LFG post you create using **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)**', inline=False) msg_followers.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: msg_followers.set_thumbnail(url=inter.user.avatar.url) except AttributeError: msg_followers.set_thumbnail(url=client.user.avatar.url) pass msg_followers.timestamp = datetime.datetime.now() msg_followers.set_footer(text=txt_footer + str(msg_followers.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_followers.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: if not dm_channel: msg_followers.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) else: msg_followers.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) pass await inter.followup(embed=msg_followers, ephemeral=True) if len(followers_list) > 1024: if len(followers_list) > 1900: await inter.followup(content='👥┃**Followers List:**\n' + followers_list[:1900] + '...', ephemeral=True) else: await inter.followup(content='👥┃**Followers List:**\n' + followers_list[:1900], ephemeral=True) # ################ Context Ticket ######################## @slash.message_command(name="📩┃Ticket Status") async def status(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'issue') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets_issue = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets_issue = response_tickets_issue + '> **Report ID:** ' + str(ticket['id']) + '\n> **Report Content:** ' + content + '\n> **Report Status:** ' + ticket['status'] + '\n\n' else: break sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'suggestion') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets_suggest = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets_suggest = response_tickets_suggest + '> **Suggestion ID:** ' + str(ticket['id']) + '\n> **Suggestion Content:** ' + content + '\n> **Suggestion Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='<:logo:908953639085821973>┃Open Steam LFG Service Tickets', description='See below your currently open tickets and their statuses.', color=0xffffff) if response_tickets_issue: msg_report.add_field(name='🛠️┃Open error report Tickets', value='See below the error reports you currently have open:\n\n' + response_tickets_issue[:1024], inline=False) else: msg_report.add_field(name='🛠️┃Open error report Tickets', value='Currently you have no open error report tickets.', inline=False) if response_tickets_suggest: msg_report.add_field(name='📝┃Open Suggestion Tickets', value='See below the suggestions you currently have open:\n\n' + response_tickets_suggest[:1024], inline=False) else: msg_report.add_field(name='📝┃Open Suggestion Tickets', value='Currently you have no open suggestion tickets.', inline=False) msg_report.add_field(name='❔┃Future Reports', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another error report or suggestion, any questions please contact developer <@224349699061186570>.', inline=False) msg_report.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report, ephemeral=True) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a error report we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass # ################ Context Report ######################## @slash.message_command(name="🔨┃Report Error") async def report(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'issue') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets = response_tickets + '> **Report ID:** ' + str(ticket['id']) + '\n> **Report Content:** ' + content + '\n> **Report Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='🛠️┃Submit Error Report', description='In order to log your encountered error or issue, please respond to this message using the format outlined below (Max 4000 Characters).\n\n**You are permitted to have open multiple report tickets at a time.**', color=0xffffff) if response_tickets: msg_report.add_field(name='📑┃Open Error Report Tickets', value='See below the error reports you currently have open:\n\n' + response_tickets[:1024], inline=False) else: msg_report.add_field(name='📑┃Open Error Report Tickets', value='Currently you have no open error report tickets.', inline=False) msg_report.add_field(name='❔┃Response Instructions', value='Provide below a text response, not including any files:\n• **Be precise:** Strive for one error per report. Include images, datetimes, used command/feature and, steps to reproduce.\n• **Be timely:** Report issues as soon as you encounter them, the sooner then the greater chance of it being included in the next patch!\n• **Offer continuing support:** Reports should not be a one and done situation. If able please follow up on issues you have seen not fixed yet and attempt to test them again after patches!', inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report) await inter.followup(embed=Embed(title='🛠️┃Instructions Sent', description='<@284839059157942274> has direct messaged you instructions!', color=0xffffff), ephemeral=True) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a error report we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass else: response = await client.wait_for('message', check=lambda message: message.author == inter.author) response = response.content[:1900] sql = "INSERT INTO submissions (type, content, discord_id) VALUES (%s, %s, %s)" val = ('issue', str(response), inter.author.id) await mysql_commit(sql=sql, val=val) msg_report_confirm = Embed(title='<:check:902430116234285136>┃Error Report Submitted', description='Thank you for your time in providing this valuable error report. We have now logged your issue and will begin investigating as soon as we are able. You can expect to hear back from once we have begun processing your report.', color=0xffffff) msg_report_confirm.add_field(name='❔┃Future Reports', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another error report, any questions please contact developer <@224349699061186570>.', inline=False) msg_report_confirm.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report_confirm.timestamp = datetime.datetime.now() msg_report_confirm.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report_confirm.set_footer(text=txt_footer + str(msg_report_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report_confirm) developer = await client.fetch_user(224349699061186570) await developer.send(content='❗┃Error Report Submitted\n> **Submitting User:** <@' + str(inter.author.id) + '>\n> **Report Content:** ' + response) # ################ Context Feedback ######################## @slash.message_command(name="📝┃Feedback") async def suggest(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'suggestion') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets = response_tickets + '> **Suggestion ID:** ' + str(ticket['id']) + '\n> **Suggestion Content:** ' + content + '\n> **Suggestion Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='📝┃Submit Suggestion', description='In order to log your suggestion, please respond to this message using the format outlined below (Max 4000 Characters).\n\n**You are permitted to have open suggestion tickets at a time.**', color=0xffffff) if response_tickets: msg_report.add_field(name='📑┃Open Suggestion Tickets', value='See below the suggestions you currently have open:\n\n' + response_tickets[:1024], inline=False) else: msg_report.add_field(name='📑┃Open Suggestion Tickets', value='Currently you have no open suggestion tickets.', inline=False) msg_report.add_field(name='❔┃Response Instructions', value='Provide below a text response, not including any files:\n• **Be specific:** Avoid limited general comments, try to include examples.\n• **Be realistic:** Feedback should focus on what can be reasonably achieved.\n• **Be timely:** Being prompt is key since feedback loses its impact if delayed too long.\n• **Balance the content:** Begin by providing comments on specific strengths. Then identify specific areas of improvement and ways to make changes.\n• **Offer continuing support:** Feedback should be a continuous process, not a one-time event. After offering feedback, make a conscious effort to follow up.', inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_image(url='https://media4.giphy.com/media/ZF8GoFOeBDwHFsVYqt/giphy.gif?cid=ecf05e47ren3clsuawrqv7zttx33laf3tj5fqkewbmfneysj&rid=giphy.gif&ct=g') msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report) await inter.followup(embed=Embed(title='📝┃Instructions Sent', description='<@284839059157942274> has direct messaged you instructions!', color=0xffffff), ephemeral=True) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a suggestion we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass else: response = await client.wait_for('message', check=lambda message: message.author == inter.author) response = response.content[:1900] sql = "INSERT INTO submissions (type, content, discord_id, status) VALUES (%s, %s, %s, %s)" val = ('suggestion', str(response), inter.author.id, 'Pending Review') await mysql_commit(sql=sql, val=val) msg_report_confirm = Embed(title='<:check:902430116234285136>┃Suggestion Submitted', description='Thank you for your time in providing this valuable feedback. We have now logged your suggestion and will review it as soon as we are able. You can expect to hear back from once we have begun processing your ticket.', color=0xffffff) msg_report_confirm.add_field(name='❔┃Future Suggestions', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another suggestion, any questions please contact developer <@224349699061186570>.', inline=False) msg_report_confirm.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report_confirm.timestamp = datetime.datetime.now() msg_report_confirm.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report_confirm.set_footer(text=txt_footer + str(msg_report_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report_confirm) developer = await client.fetch_user(224349699061186570) await developer.send(content='❕┃Suggestion Submitted\n> **Submitting User:** <@' + str(inter.author.id) + '>\n> **Suggestion Content:** ' + response) # ################ Context Support ######################## @slash.message_command(name="🌟┃Support Us") async def support(inter): await inter.send(embed=msg_process, ephemeral=True, type=5) supportus_buttons = [ActionRow( Button(style=ButtonStyle.secondary, label="Ticket Status", emoji='📩', custom_id='faq_status'), Button(style=ButtonStyle.secondary, label="Submit Error Report", emoji='🛠️', custom_id='faq_report'), Button(style=ButtonStyle.secondary, label="Submit Suggestion", emoji='📝', custom_id='faq_suggest'), Button(style=ButtonStyle.link, label="Rate Service", emoji='🌟', url='https://top.gg/bot/284839059157942274') )] support_embed = Embed(title='<:logo:908953639085821973>┃Support Us', description='Consider supporting <@284839059157942274> by rating our service, leaving feedback and, reporting errors below!', color=0xffffff) support_embed.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) support_embed.timestamp = datetime.datetime.now() support_embed.set_footer(text=txt_footer + str(support_embed.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) support_embed.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) await inter.followup(embed=support_embed, components=supportus_buttons, ephemeral=True) # ################ On Dropdown ######################## @client.event async def on_dropdown(inter: MessageInteraction): await inter.send(embed=msg_process, ephemeral=True, type=5) if inter.component.selected_options is not None: if inter.component.selected_options[0].value == 'setup_choose-lfg': sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() msg_network = Embed(title='✨┃Set Global LFG Network Preference', description='This network is used to store all LFG posts from participating servers, respond below to Opt-In/Out your Discord server to this feature.', color=0xffffff) msg_network.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Current Global LFG Network Preference', value='`' + inter.guild.name + '` is currently Opted-**' + ids[0]['global_lfg_opt'] + '** the Global LFG Network.') msg_network.add_field(name='❔┃Global LFG Network Features', value='• Using `/notify` or `/search` will inform any user in any Discord server anywhere of LFG posts matching their criteria found in any Discord servers on the Network.\n\n• By Opt-ing into the network, your server\'s LFG posts will be visisble to anyone using our bot.\n\n• By Opt-ing into the network, you allow our service to maintain a Discord Invite Link to your Discord server.\n• Said invite link will be attached to your Server\'s LFG posts found when using `/notify` or `/search` so anyone can join said server to talk connect with a LFG host.', inline=False) msg_network.timestamp = datetime.datetime.now() msg_network.set_footer(text=txt_footer + str(msg_network.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_network.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_network.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_network, components=[ActionRow(sopt_setup_lfg)], ephemeral=True) elif inter.component.selected_options[0].value == 'setup_choose-restrict': sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() lfg_restrictions = '' restrictions_dict = ast.literal_eval(ids[0]['lfg_restrictions']) if restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - All games allowed\n' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: lfg_restrictions = lfg_restrictions + '• Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/\n' pass else: lfg_restrictions = lfg_restrictions + '• [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)\n' elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - ' if restrictions_dict['paired_restrictions'][channel_id]['app_ids']: for appid in restrictions_dict['paired_restrictions'][channel_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_restrictions = lfg_restrictions + 'All games allowed' lfg_restrictions = lfg_restrictions + '\n' else: lfg_restrictions = '• No restrictions currently in place for any channels or games. `/host` can be used in any channel for any game.' prompt_restrictions = '`' + inter.guild.name + '` Restrictions: \n\n' + lfg_restrictions msg_restrict = Embed(title='🛠️┃Setup LFG Restrictions', description='See below instructions and choices on restricting channels and/or games when using `/host`.', color=0xffffff) msg_restrict.add_field(name='❔┃Why Restrictions', value='A key feature of our LFG service is the ability to restrict which games can be LFG\'ed for in your Discord Server. Alongside side this or independently you can also restrict LFG posts created with `/host` to certain channels, as to help keep things tidy.', inline=False) if len(prompt_restrictions) <= 1024: msg_restrict.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Current LFG Restrictions Preference', value=prompt_restrictions, inline=False) msg_restrict.timestamp = datetime.datetime.now() msg_restrict.set_footer(text=txt_footer + str(msg_restrict.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_restrict, components=[ActionRow(sopt_setup_restrict)]) if len(prompt_restrictions) > 1024: await inter.followup(content='<:combine:902429705100214282>┃Discord Server\'s Current LFG Restrictions Preference\n\n' + prompt_restrictions, ephemeral=True) elif inter.component.selected_options[0].value == 'setup_choose-channels': sql = "SELECT * FROM notifications WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) subscriptions_dict = sql_connect.fetchone() if subscriptions_dict: prompt_notifications = '' subscriptions_dict = ast.literal_eval(subscriptions_dict['notifications']) for channelid, appids in subscriptions_dict.items(): if bool([guild_channel for guild_channel in inter.guild.text_channels if (str(guild_channel.id) == str(channelid))]): if appids: prompt_notifications = prompt_notifications + '• <#' + channelid + '>:' for app_id_dict in appids: app_id = list(app_id_dict.keys())[0] payload = {'appids': app_id} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() userids = app_id_dict[app_id] users_prompt = '[**Hosts:** ' if userids: for user_id in userids: try: user = await client.fetch_user(int(user_id)) except: try: guild = await client.fetch_guild(int(user_id)) except: if user_id != userids[-1]: users_prompt = users_prompt + '`Invalid User/Server: **' + user_id + '**`, ' else: users_prompt = users_prompt + '`Invalid User/Server: **' + user_id + '**`' pass else: if user_id != userids[-1]: users_prompt = users_prompt + '`' + guild.name + '`, ' else: users_prompt = users_prompt + '`' + guild.name + '`' pass else: if user_id != userids[-1]: users_prompt = users_prompt + '<@' + user_id + '>, ' else: users_prompt = users_prompt + '<@' + user_id + '>' try: response[app_id]['data'] except KeyError: if app_id_dict != appids[-1]: if userids: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + '],' else: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/),' else: if userids: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + ']\n' else: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)\n' pass else: if app_id_dict != appids[-1]: if userids: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + '],' else: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/),' else: if userids: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + ']\n' else: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)\n' else: prompt_notifications = prompt_notifications + '• <#' + channelid + '>' + ' - Notifications enabled for new LFG Posts regardless of game.' else: prompt_notifications = prompt_notifications + '• ' + channelid + ' - Invalid Channel ID (*Possibly Deleted from Server*) ' else: prompt_notifications = 'No Channel Notifications are currently enabled for your server.' msgchannels = Embed(title='✨┃Set Channel Notification Preferences', description='Designate which channels to automatically post to any new LFG Requests submitted to the Global LFG Network, for any specific games.', color=0xffffff) if len(prompt_notifications) <= 1024: msgchannels.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences', value=prompt_notifications) elif len(prompt_notifications) > 1024: await inter.followup(content='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences\n' + prompt_notifications, ephemeral=True) msgchannels.add_field(name='❔┃Channel Notification Purpose', value='• A user creates a new LFG Post using `/host`. If their server is Opt-Into the Global LFG Network, users on other servers see those posts if subscribed to notifications using `/notify`.\n\n• You may alternatively designate channels in your server to showcase new posts on the Global LFG Network.\n\n• This feature is especially useful for those who wish not to be directly informed via DM. It is also useful for larger servers wishing to showcase all active LFG Posts for certain games.\n\n• Select `🔗 Configure Discord Links` to control whether to show a `💻 Join Discord` button on Global LFG Posts displayed in said designated channels.', inline=False) msgchannels.timestamp = datetime.datetime.now() msgchannels.set_footer(text=txt_footer + str(msgchannels.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgchannels.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgchannels.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msgchannels, components=[ActionRow(sopt_setup_channels)]) elif (inter.component.selected_options[0].value == 'notify_channels-setup') | (inter.component.selected_options[0].value == 'notify_channels-invites') | (inter.component.selected_options[0].value == 'notify_channels-none'): if inter.component.selected_options[0].value == 'notify_channels-setup': msg_prompt = Embed(title='🔔┃Channel Notification Preferences', description='In order to setup Channel Notifications, please respond to this message using the format outlined below.\n\n**This will completely overwrite your current Channel Notifications, so be sure to include current Role & Game(s) pairs as well!**', color=0xffffff) msg_prompt.add_field(name='❔┃Response Instructions', value='Pair a channel with User(s)/Server(s) and Game(s) in order to showcase all new posts on the Global LFG Network for said game(s) or from said User(s)/Server(s). Unpaired Channels will showcase every new post on the Global LFG Network for all games:\n\n• **Response Format:**\n\n`<channel_id_1>;<Game_Steam_Store_Page_URL_1>,<Game_Steam_Store_Page_URL_2>`\n\n`<channel_id_2>;<Game_Steam_Store_Page_URL_1>(<User_ID_1>+<User_ID_2>+<User_ID_3>),<Game_Steam_Store_Page_URL_2>`\n\n• **Example:**\n\n `<#227603450311999489>;https://store.steampowered.com/app/924970/Back_4_Blood/,https://store.steampowered.com/app/1063730/New_World`\n\n`891785797672521748;https://store.steampowered.com/app/1466860/Age_of_Empires_IV/(<@284839059157942274>+<@224349699061186570>+912156910118129684),https://store.steampowered.com/app/813780/Age_of_Empires_II_Definitive_Edition/,https://store.steampowered.com/app/1172470/Apex_Legends` \n\n**Note:** You may alternatively mention a user using `@` or a channel using `#` instead of providing the ID.', inline=False) msg_prompt.timestamp = datetime.datetime.now() msg_prompt.set_footer(text=txt_footer + str(msg_prompt.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_prompt.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_prompt.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_prompt, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_msg = response response_pairs_submitted = response.content[:1900].split() response_accepted = '' response_rejected = '' pair_seperated = [] pair_approved = {} channels_rejected = [] urls_rejected = [] users_rejected = [] for pair in response_pairs_submitted: if (len(pair.split(";", 1)) >= 2) and (pair.split(";", 1)[1]): pair_seperated.append(pair.split(';')) else: pair = pair.replace(';', '') pair_seperated.append([pair]) for sub_pair in pair_seperated: pair_seperated = list(dict((x[0], x) for x in pair_seperated).values()) try: sub_pair[1] except IndexError: pass else: sub_pair[1] = sub_pair[1].split(',') sub_pair[1] = list((filter(None, list(set(sub_pair[1]))))) for sub_pair in pair_seperated: if ('<#' in sub_pair[0]) & ('>' in sub_pair[0]): sub_pair[0] = sub_pair[0].replace('<#', '').replace('>', '') if bool([guild_channel for guild_channel in inter.guild.text_channels if (str(guild_channel.id) == str(sub_pair[0]))]): urls_remove = [] if len(sub_pair) > 1: for idx, url in enumerate(sub_pair[1]): orignal_url = url userids = [] uuids_remove = [] if re.findall('\(.*?\)', url): userids = re.findall('\(.*?\)', url)[0].replace('(', '').replace(')', '') userids = userids.split('+') url = url.split(re.findall('\(.*?\)', url)[0])[0] for idx_internal, user_id in enumerate(userids): if ('<@' in user_id) & ('>' in user_id): user_id = user_id.replace('<@', '').replace('>', '').replace('!', '') userids[idx_internal] = user_id if user_id.isnumeric(): try: user = await client.fetch_user(int(user_id)) except: try: guild = await client.fetch_guild(int(user_id)) except: uuids_remove.append(user_id) pass pass else: uuids_remove.append(user_id) if uuids_remove: for user_id in uuids_remove: if user_id not in users_rejected: users_rejected.append(user_id) userids.remove(user_id) if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] app_list = [] for entry in sub_pair[1]: if type(entry) is dict: app_list.append(list(entry.keys())[0]) if appid not in app_list: payload = {'appids': appid} response_steam = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response_steam: if response_steam[appid]['success']: if userids: userids = list(dict.fromkeys(userids)) sub_pair[1][idx] = {appid: userids} else: sub_pair[1][idx] = {appid: []} else: urls_remove.append(url) else: urls_remove.append(url) else: urls_remove.append(url) else: urls_remove.append(orignal_url) if urls_remove: for url in urls_remove: if url not in urls_rejected: urls_rejected.append(url) sub_pair[1].remove(url) pair_approved[sub_pair[0]] = sub_pair[1] else: pair_approved[sub_pair[0]] = {} else: channels_rejected.append(sub_pair[0]) if channels_rejected: for sub_pair in pair_approved: if sub_pair in channels_rejected: del pair_approved[sub_pair] prompt_reject = '' for cuid in channels_rejected: if cuid != channels_rejected[-1]: prompt_reject = prompt_reject + '`' + cuid + '`, ' else: prompt_reject = prompt_reject + '`' + cuid + '`' response_rejected = response_rejected + '**Rejected Channel IDs:**\n• ' + prompt_reject + '\n\n' if urls_rejected: prompt_reject = '' for url in urls_rejected: if url != urls_rejected[-1]: prompt_reject = prompt_reject + '`' + url + '`, ' else: prompt_reject = prompt_reject + '`' + url + '`' response_rejected = response_rejected + '**Rejected Game URLs:**\n• ' + prompt_reject + '\n\n' if users_rejected: prompt_reject = '' for uuid in users_rejected: if uuid != users_rejected[-1]: prompt_reject = prompt_reject + '`' + uuid + '`, ' else: prompt_reject = prompt_reject + '`' + uuid + '`' response_rejected = response_rejected + '**Rejected User IDs:**\n• ' + prompt_reject + '\n\n' if pair_approved: for channelid in pair_approved: response_apps = '' response_accepted = response_accepted + '• <#' + channelid + '> - ' if pair_approved[channelid]: for appid_dict in pair_approved[channelid]: for appid, userids in appid_dict.items(): payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: app_name = 'Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: app_name = '[' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' users = '' if userids: for uuid in userids: try: user = await client.fetch_user(int(uuid)) except: try: guild = await client.fetch_guild(int(uuid)) except: pass else: if uuid != userids[-1]: users = users + '`' + guild.name + '`, ' else: users = users + '`' + guild.name + '`' pass else: if uuid != userids[-1]: users = users + '<@' + uuid + '>, ' else: users = users + '<@' + uuid + '>' if users: response_apps = response_apps + app_name + '[**Hosts:** ' + users + ']' else: response_apps = response_apps + app_name if appid_dict != pair_approved[channelid][-1]: response_apps = response_apps + ', ' response_accepted = response_accepted + response_apps + '\n' else: response_accepted = response_accepted + 'Showcase all Global LFG Posts for any games and users\n' prompt_accept = 'The below Channel(s) paired with User(s)/Server(s) and Game(s) were verified to be valid Server Channels(s), Discord User(s)/Server(s) & Steam Store listed game(s), channel notifications are now enabled for the below:\n\n' + response_accepted prompt_reject = 'The below Channel(s), User(s)/Server(s) and, Game(s) were not verified to be valid Server Channels(s), Discord User(s)/Server(s) & Steam Store listed game(s), please re-copy your input to fix mistakes then re-run `/setup` to retry:\n\n' + response_rejected channel_notify_update = Embed(title='<:check:902430116234285136>┃Discord Server\'s Channel Notifications Updated', description='Thank you for providing your input on the Server\'s Channel Notifications preference, succesfully updated!', color=0xffffff) channel_notify_update.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated Channel Notifications Preference', value='`' + inter.guild.name + '` - Pair a channel to be notified of game(s) and corresponding user(s) on the Global LFG Network.\n\n**Note:** To update Channel Notifications in the future simply re-run `/setup`', inline=False) if bool(response_accepted): if len(prompt_accept) <= 1024: channel_notify_update.add_field(name='✨┃Accepted Channel Notification Pairs', value=prompt_accept, inline=False) if bool(response_rejected): if len(prompt_reject) <= 1024: channel_notify_update.add_field(name='❌┃Rejected Channel Notification Pairs', value=prompt_reject, inline=False) channel_notify_update.timestamp = datetime.datetime.now() channel_notify_update.set_footer(text=txt_footer + str(channel_notify_update.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: channel_notify_update.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: channel_notify_update.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=channel_notify_update) if bool(response_accepted) & (len(prompt_accept) > 1024): await inter.followup(content='✨┃Accepted Channel Notification Pairs\n\n' + prompt_accept, ephemeral=True) if bool(response_rejected) & (len(prompt_reject) > 1024): await inter.followup(content='❌┃Rejected Channel Notification Pairs\n\n' + prompt_reject, ephemeral=True) if bool(response_accepted): sql = "SELECT * FROM notifications WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) guild_entry = sql_connect.fetchone() if guild_entry: sql = "UPDATE notifications SET notifications = %s WHERE guild_id = %s" val = (str(pair_approved), inter.guild.id) await mysql_commit(sql=sql, val=val) else: sql = "INSERT INTO notifications (guild_id, notifications) VALUES (%s, %s)" val = (inter.guild.id, str(pair_approved)) await mysql_commit(sql=sql, val=val) if response_rejected == '': try: await response_msg.delete() except: pass elif inter.component.selected_options[0].value == 'notify_channels-invites': sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) external_invites = ast.literal_eval(sql_connect.fetchone()['setup_options']) if external_invites['external_invites'] == 'Enabled': current_preference = 'LFG Posts in setup channels currently will display a `💻 Join Discord` button, opening to an external Server Invite link.' else: current_preference = 'LFG Posts in setup channels will only display `🕹️ Join Game` and `👥 Add Host as Friend` buttons on posts.' msgchannels = Embed(title='✨┃Set External Invite Preference', description='Designate whether LFG Posts displayed in your setup channels, have attached their external Discord Server Invite.', color=0xffffff) msgchannels.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current External Invite Preference', value='`' + inter.guild.name + '` - ' + current_preference, inline=False) msgchannels.add_field(name='❔┃External Invite Purpose', value='• A user creates a new LFG Post using `/host`. If their server is Opt-Into the Global LFG Network, users on other servers see those posts if subscribed to notifications using `/notify`.\n\n• A concern for larger servers wishing to showcase all active LFG Posts for certain games or users, is to avoid advertising Discord servers they do not moderate.\n\n• This options allows you to only show `🕹️ Join Game` and `👥 Add Host as Friend` buttons on posts to avoid advertising links to external Discord servers.', inline=False) msgchannels.timestamp = datetime.datetime.now() msgchannels.set_footer(text=txt_footer + str(msgchannels.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgchannels.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgchannels.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgchannels, components=[ActionRow(sopt_channels_invites)], ephemeral=True) else: msg_setup_confirm = Embed(title='<:check:902430116234285136>┃Channel Notification Preferences Updated', description='Thank you for providing your input for the Server\'s Channel Notifications Preference, succesfully updated!', color=0xffffff) msg_setup_confirm.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences', value='`' + inter.guild.name + '` - No channel notifications currently in place any longer for any games or users.\n\n**Note:** To update channel notifications in the future simply re-run `/setup`', inline=False) msg_setup_confirm.timestamp = datetime.datetime.now() msg_setup_confirm.set_footer(text=txt_footer + str(msg_setup_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_setup_confirm, ephemeral=True) sql = "DELETE FROM notifications WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) elif (inter.component.selected_options[0].value == 'channels_choice-show') | (inter.component.selected_options[0].value == 'channels_choice-none'): if inter.component.selected_options[0].value == 'channels_choice-show': updated_preference = 'LFG Posts in setup channels will now also display a `💻 Join Discord` button, opening to an external Server Invite link.' else: updated_preference = 'LFG Posts in setup channels will now only display `🕹️ Join Game` and `👥 Add Host as Friend` buttons on posts.' msg_setup_confirm = Embed(title='<:check:902430116234285136>┃External Invite Preference Updated', description='Thank you for providing your input for the Server\'s External Invite Preference, succesfully updated!', color=0xffffff) msg_setup_confirm.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current External Invite Preference', value='`' + inter.guild.name + '` - ' + updated_preference, inline=False) msg_setup_confirm.timestamp = datetime.datetime.now() msg_setup_confirm.set_footer(text=txt_footer + str(msg_setup_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_setup_confirm, ephemeral=True) sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) external_invites = ast.literal_eval(sql_connect.fetchone()['setup_options']) if inter.component.selected_options[0].value == 'channels_choice-show': external_invites.update({"external_invites":"Enabled"}) else: external_invites.update({"external_invites":"Disabled"}) sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(external_invites), inter.guild.id) await mysql_commit(sql=sql, val=val) elif inter.component.selected_options[0].value == 'setup_choose-roles': sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) roles = sql_connect.fetchall() lfg_roles = '' roles_dict = ast.literal_eval(roles[0]['lfg_roles']) if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: lfg_roles = lfg_roles + '• <@&' + str(role_id) + '> - ' if roles_dict['paired_roles'][role_id]['app_ids']: for appid in roles_dict['paired_roles'][role_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' [' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_roles = lfg_roles + ' [' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_roles = lfg_roles + 'Will be pinged on `/host` usage for all games' lfg_roles = lfg_roles + '\n' else: lfg_roles = '• No role pings currently in place for any games.' prompt_roles = '`' + inter.guild.name + '` LFG Role Pings: \n\n' + lfg_roles msgroles = Embed(title='✨┃Set LFG Role Ping Preferences', description='Designate which roles to automatically ping upon the creation of LFG Requests for specific games.', color=0xffffff) msgroles.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current LFG Role Ping Preferences', value=prompt_roles) msgroles.add_field(name='❔┃LFG Role Ping Purpose', value='• LFG Role Pings are used for mentioning a specific role for desired games upon usage of `/host`.\n\n• You may pair a role with as many games as you would like, to maximize LFG Request visibility.\n\n• This feature is especially useful for larger servers with very active LFG channels, allowing users to be notified upon creation of a LFG Request.', inline=False) msgroles.timestamp = datetime.datetime.now() msgroles.set_footer(text=txt_footer + str(msgroles.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgroles.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgroles.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msgroles, components=[ActionRow(sopt_setup_roles)]) elif (inter.component.selected_options[0].value == 'post_roles-setup') | (inter.component.selected_options[0].value == 'post_roles-none'): if inter.component.selected_options[0].value == 'post_roles-setup': msg_restrict_3 = Embed(title='🛠️┃LFG Role Ping Preferences', description='In order to setup LFG Role pings, please respond to this message using the format outlined below.\n\n**This will completely overwrite your current role pings, so be sure to include current Role & Game(s) pairs as well!**', color=0xffffff) msg_restrict_3.add_field(name='❔┃Response Instructions', value='Pair a role with game(s) in order to ping users on usage of `/host` for said game(s). Roles not paired with game(s) will be pinged on every usage of `/host` for all games:\n\n• **Response Format:**\n\n`<role_id_1>;<Game_Steam_Store_Page_URL_1>,<Game_Steam_Store_Page_URL_2>,<Game_Steam_Store_Page_URL_3>`\n\n`<role_id_1>;<Game_Steam_Store_Page_URL_1>,<Game_Steam_Store_Page_URL_2>,<Game_Steam_Store_Page_URL_3>`\n\n• **Example:**\n\n`904469396892823633;https://store.steampowered.com/app/281990/Stellaris/,https://store.steampowered.com/app/1151340/Fallout_76/,https://store.steampowered.com/app/107410/Arma_3/`\n\n`904469434582851644;https://store.steampowered.com/app/910490/Killsquad/,https://store.steampowered.com/app/1543030/Sword_and_Fairy_7/,https://store.steampowered.com/app/1335530/Alisa/`\n\n**Note:** You may alternatively mention a role using `@` instead of providing it\'s ID.', inline=False) msg_restrict_3.timestamp = datetime.datetime.now() msg_restrict_3.set_footer(text=txt_footer + str(msg_restrict_3.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_3.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_3.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict_3, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_msg = response response_pairs_submitted = response.content[:1900].split() response_accepted = '' response_rejected = '' pair_seperated = [] pair_approved = [] pair_rejected = [] urls_rejected = [] for pair in response_pairs_submitted: if (len(pair.split(";", 1)) >= 2) and (pair.split(";", 1)[1]): pair_seperated.append(pair.split(';')) else: pair = pair.replace(';', '') pair_seperated.append([pair]) for sub_pair in pair_seperated: pair_seperated = list(dict((x[0], x) for x in pair_seperated).values()) try: sub_pair[1] except IndexError: pass else: sub_pair[1] = sub_pair[1].split(',') sub_pair[1] = list((filter(None, list(set(sub_pair[1]))))) for sub_pair in pair_seperated: if ('<@&' in sub_pair[0]) & ('>' in sub_pair[0]): sub_pair[0] = sub_pair[0].replace('<@&', '').replace('>', '') if bool([item for item in inter.guild.roles if (str(item.id) == sub_pair[0])]): urls_remove = [] try: sub_pair[1] except IndexError: pair_approved.append(sub_pair) pass else: for idx, url in enumerate(sub_pair[1]): if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response: if response[appid]['success']: sub_pair[1][idx] = appid else: urls_remove.append(url) else: urls_remove.append(url) if urls_remove is not None: sub_pair[1] = list(set(sub_pair[1]) - set(urls_remove)) pair_approved.append(sub_pair) for url in urls_remove: if url not in urls_rejected: urls_rejected.append(url) else: pair_rejected.append(sub_pair) pairs = {} pair_dict = {} for pair in pair_approved: try: pair[1] except IndexError: pair_dict_new = {pair[0]: {'app_ids': ''}} response_accepted = response_accepted + '• <@&' + str(pair[0]) + '> - Will be pinged on `/host` usage for all games\n' pass else: pair_dict_new = {pair[0]: {'app_ids': pair[1]}} titles = '' for appid in pair[1]: payload = {'appids': appid} response = ( requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if appid is not pair[1][-1]: titles = titles + '[' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: titles = titles + '[' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/)' response_accepted = response_accepted + '• <@&' + str(pair[0]) + '> - ' + titles + '\n' pair_dict = {**pair_dict, **pair_dict_new} pairs = {**pairs, **pair_dict} for pair in pair_rejected: try: pair[1] except IndexError: response_rejected = response_rejected + '• `' + str(pair[0]) + '`\n' pass else: titles = '' for appid in pair[1]: if appid is not pair[:-1]: titles = titles + appid + ', ' else: titles = titles + appid response_rejected = response_rejected + '• `' + str(pair[0]) + ' - ' + titles + '`\n' for url in urls_rejected: response_rejected = response_rejected + '• `' + url + '`\n' prompt_accept = 'The below Role(s) & URL(s) were verified to be valid Server Role(s) & Steam Store listed game(s), `/host` usage will now ping said role(s) for said game(s):\n\n' + response_accepted prompt_reject = 'The below URL(s) were not verified to be valid Steam Store listed game(s), please re-copy your Role ID(s) & game URL(s) then re-run `/setup` to retry:\n\n' + response_rejected msg_restrict_3_update = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Role Pings Updated', description='Thank you for providing your input on the Server\'s LFG Role Pings preference, succesfully updated!', color=0xffffff) msg_restrict_3_update.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated LFG Role Ping Preference', value='`' + inter.guild.name + '` - Pair a role with game(s) together.\n\n**Note:** To update LFG Role Pings in the future simply re-run `/setup`', inline=False) if bool(response_accepted): if len(prompt_accept) <= 1024: msg_restrict_3_update.add_field(name='✨┃Accepted Role & Game Pairs', value=prompt_accept, inline=False) if bool(response_rejected): if len(prompt_reject) <= 1024: msg_restrict_3_update.add_field(name='❌┃Rejected Role & Game Pairs', value=prompt_reject, inline=False) msg_restrict_3_update.timestamp = datetime.datetime.now() msg_restrict_3_update.set_footer(text=txt_footer + str(msg_restrict_3_update.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_3_update.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_3_update.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_restrict_3_update) if bool(response_accepted) & (len(prompt_accept) > 1024): await inter.followup(content='✨┃Accepted Role & Game Pairs\n\n' + prompt_accept, ephemeral=True) if bool(response_rejected) & (len(prompt_reject) > 1024): await inter.followup(content='❌┃Rejected Role & Game Pairs\n\n' + prompt_reject, ephemeral=True) if bool(response_accepted): lfg_roles = {"paired_roles": pairs} sql = "UPDATE guilds SET lfg_roles = %s WHERE guild_id = %s" val = (str(lfg_roles), inter.guild.id) await mysql_commit(sql=sql, val=val) if response_rejected == '': try: await response_msg.delete() except: pass else: msg_setup_confirm = Embed(title='<:check:902430116234285136>┃LFG Role Ping Preferences Updated', description='Thank you for providing your input for the Server\'s LFG Role Ping Preference, succesfully updated!', color=0xffffff) msg_setup_confirm.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current LFG Role Ping Preferences', value='`' + inter.guild.name + '` - No role pings currently in place any longer for games.\n\n**Note:** To update role pings in the future simply re-run `/setup`', inline=False) msg_setup_confirm.timestamp = datetime.datetime.now() msg_setup_confirm.set_footer(text=txt_footer + str(msg_setup_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_setup_confirm, ephemeral=True) lfg_roles = {"paired_roles": {}} sql = "UPDATE guilds SET lfg_roles = %s WHERE guild_id = %s" val = (str(lfg_roles), inter.guild.id) await mysql_commit(sql=sql, val=val) elif inter.component.selected_options[0].value == 'setup_choose-remove': sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() msgremove = Embed(title='✨┃Specify LFG Request Auto-Delete Timer', description='Designate a auto-delete time for the messages of LFG Requests, respond below to specify your preferred timer or to not use this feature.', color=0xffffff) if ids[0]['lfg_remove'] == 0: msgremove.add_field(name='⏲️┃Discord Server\'s Current Auto-Delete Timer', value='`' + inter.guild.name + '` currently maintains **no auto-delete timer** for the messages of LFG Requests.', inline=False) else: msgremove.add_field(name='⏲️┃Discord Server\'s Current Auto-Delete Timer', value='`' + inter.guild.name + '` currently maintains a auto-delete timer of **' + str(ids[0]['lfg_remove']) + '** minutes for the messages of LFG Requests.', inline=False) msgremove.add_field(name='❔┃LFG Request Auto-Delete Timer Purpose', value='• LFG Request messages are sent on usage of `/host`, they can be auto-deleted after specified minutes in order to assist keeping a channel fresh and clean.\n\n• By specifying a time in minutes, we will automatically delete said messages and remove them from the Global Network upon said time completing.\n\n• This feature is especially useful for larger servers with very active LFG channels, seeking to de-clutter thier channels.\n\n• This feature will **not** automatically delete threads created for LFG Request messages, as in order to not disrupt team communications.', inline=False) msgremove.timestamp = datetime.datetime.now() msgremove.set_footer(text=txt_footer + str(msgremove.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgremove.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgremove.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgremove, components=[ActionRow(sopt_setup_remove)], ephemeral=True) elif (inter.component.selected_options[0].value == 'setup_choose-banner') | (inter.component.selected_options[0].value == 'setup_choose-threads') | (inter.component.selected_options[0].value == 'setup_choose-active') | (inter.component.selected_options[0].value == 'setup_choose-host'): sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) options = sql_connect.fetchall() preference_prompt = '' if inter.component.selected_options[0].value == 'setup_choose-banner': preference_dict = ast.literal_eval(options[0]['setup_options']) if preference_dict['banner_setup'] == 'Enabled': preference_prompt = 'Default banners are **enabled** for new LFG Posts.' else: preference_prompt = 'Default banners are **disabled** for new LFG Posts.' msgbanner = Embed(title='🖼️┃Set LFG Post Banner Preference', description='Designate whether to enable or disable showing a game\'s default banner image on every new LFG Post.', color=0xffffff) msgbanner.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Preference', value=preference_prompt) msgbanner.add_field(name='❔┃LFG Post Banner Purpose', value='• In order to assist users when searching for a game, we attach the Steam Store banner image to every new LFG Post.\n\n• This feature is especially useful for organization in very active LFG channels if they allow users to post for multiple games in one channel.\n\n• A user whom provides a banner URL for `/host`, will not be affected by this prefernce, only those who do not will be.', inline=False) msgbanner.timestamp = datetime.datetime.now() msgbanner.set_footer(text=txt_footer + str(msgbanner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgbanner, components=[ActionRow(sopt_setup_banner)], ephemeral=True) elif inter.component.selected_options[0].value == 'setup_choose-threads': preference_dict = ast.literal_eval(options[0]['setup_options']) if preference_dict['thread_setup'] == 'Enabled': preference_prompt = 'Thread auto-creation is **enabled** for new LFG Posts.' else: preference_prompt = 'Thread auto-creation is **disabled** for new LFG Posts.' msgthread = Embed(title='📝┃Set LFG Post Thread Preference', description='Designate whether to auto-create threads for all new LFG Posts.', color=0xffffff) msgthread.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Preference', value=preference_prompt) msgthread.add_field(name='❔┃LFG Post Thread Purpose', value='• By default, new threads will be created and attached to each LFG Post in order to designate a private channel for discussions.\n\n• This feature is especially useful for organization of in-game activites in very active LFG channels, where on-going discussion may easily be lost.\n\n• All created threads will automatically archive after 1 hour of inactivity to assist with cleanup.', inline=False) msgthread.timestamp = datetime.datetime.now() msgthread.set_footer(text=txt_footer + str(msgthread.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgthread.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgthread.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgthread, components=[ActionRow(sopt_setup_thread)], ephemeral=True) elif inter.component.selected_options[0].value == 'setup_choose-active': preference_dict = ast.literal_eval(options[0]['setup_options']) if preference_dict['active_setup'] == 'Enabled': preference_prompt = 'Allow users to have **multiple** LFG requests open at once.' else: preference_prompt = '**Replace** a user\'s last LFG request with their new one.' msgbanner = Embed(title='🔂┃Set Active LFG Posts Preference', description='Control users having more than one active LFG Post.', color=0xffffff) msgbanner.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Preference', value=preference_prompt) msgbanner.add_field(name='❔┃Controlling LFG Post Amount', value='• You may either auto-remove a user\'s last active LFG post on `/host` usage or allow them to have multiple LFG posts at once.\n\n• Restricting this feature is especially useful for organization in very active LFG channels where they allow users to post for multiple games in one channel.', inline=False) msgbanner.timestamp = datetime.datetime.now() msgbanner.set_footer(text=txt_footer + str(msgbanner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgbanner, components=[ActionRow(sopt_setup_active)], ephemeral=True) elif inter.component.selected_options[0].value == 'setup_choose-host': preference_dict = ast.literal_eval(options[0]['setup_options']) if preference_dict['host_setup'] == 'Enabled': preference_prompt = '/host usage **enabled** at anytime by any user.' else: preference_prompt = '/host usage **disabled**, best for if your prefer to only use /link.' msgbanner = Embed(title='🎬┃Set /host Usage Preference', description='Disable or enable /host usage by users.', color=0xffffff) msgbanner.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Preference', value=preference_prompt) msgbanner.add_field(name='❔┃/host Restriction Purpose', value='• Disabling `/host` usage will priotize usage of `/link` where users can only generate a join code, not a physical post.\n\n• This feature is practical for instances where server\'s prefer to use general text-chat conversation for LFG instead of Embed posts.\n\n• User\'s will still be able to generate join links, game permitting, as they will be prompted to use `/link` instead', inline=False) msgbanner.timestamp = datetime.datetime.now() msgbanner.set_footer(text=txt_footer + str(msgbanner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgbanner.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msgbanner, components=[ActionRow(sopt_setup_host)], ephemeral=True) elif (inter.component.selected_options[0].value == 'post_delete-setup') | (inter.component.selected_options[0].value == 'post_delete-none'): if inter.component.selected_options[0].value == 'post_delete-setup': msg_setup = Embed(title='🛠️┃Setup LFG Request Auto-Delete Timer', description='In order to setup a auto-delete timer, please respond to this message using the format outlined below.', color=0xffffff) msg_setup.add_field(name='❔┃Response Instructions', value='Please respond below only using numbers and no decimals, a time (in minutes) to set your Auto-Delete Timer:\n\n• **Response Format:**\n\n`<desired_time_int>`\n\n• **Example:**\n\n`15`', inline=False) msg_setup.timestamp = datetime.datetime.now() msg_setup.set_footer(text=txt_footer + str(msg_setup.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_setup, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_content = response.content.replace('-', '') while not response_content.isnumeric(): msg_setup_repeat = Embed(title='❌┃Invalid LFG Request Auto-Delete Timer Response', description='We apologize however the response format you provided is invalid, in order to setup a auto-delete timer, please respond to this message using the format outlined below.', color=clr_error) msg_setup_repeat.add_field(name='❔┃Response Instructions', value='Please respond below only using numbers and no decimals, a time (in minutes, max 10080, min 5) to set your Auto-Delete Timer:\n\n• **Response Format:**\n\n`<desired_time_int>`\n\n• **Example:**\n\n`15`', inline=False) msg_setup_repeat.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_setup_repeat.set_thumbnail(url=img_error) msg_setup_repeat.timestamp = datetime.datetime.now() msg_setup_repeat.set_footer(text=txt_error + str(msg_setup_repeat.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_setup_repeat.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) await inter.followup(ephemeral=True, embed=msg_setup_repeat) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_content = response.content.replace('-', '') else: msg_setup_confirm = Embed(title='<:check:902430116234285136>┃LFG Request Auto-Delete Timer Updated', description='Thank you for providing your input for the Server\'s LFG Request Auto-Delete Timer, succesfully updated!', color=0xffffff) if int(response_content) > 10080: msg_setup_confirm.add_field(name='❔┃Response Auto-Updated', value='**Note:** Your response of was greater than the allowed maximum of **10080**. Thus your response has been auto-decreased to **10080**.', inline=False) response_content = 10080 elif int(response_content) < 5: msg_setup_confirm.add_field(name='❔┃Response Auto-Updated', value='**Note:** Your response of was less than the required minimum of **5**. Thus your response has been auto-increased to **5**.', inline=False) response_content = 5 msg_setup_confirm.add_field(name='⏲️┃Discord Server\'s Updated Auto-Delete Timer', value='`' + inter.guild.name + '` currently maintains a auto-delete timer of **' + str(response_content) + '** minutes for the messages of LFG Requests.', inline=False) msg_setup_confirm.timestamp = datetime.datetime.now() msg_setup_confirm.set_footer(text=txt_footer + str(msg_setup_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_setup_confirm) response_seconds = int(response_content) * 60 sql = "UPDATE guilds SET lfg_remove = %s WHERE guild_id = %s" val = (response_seconds, inter.guild.id) await mysql_commit(sql=sql, val=val) try: await response.delete() except: pass else: msg_setup_confirm = Embed(title='<:check:902430116234285136>┃LFG Request Auto-Delete Timer Updated', description='Thank you for providing your input for the Server\'s LFG Request Auto-Delete Timer, succesfully updated!', color=0xffffff) msg_setup_confirm.add_field(name='⏲️┃Discord Server\'s Current Auto-Delete Timer', value='`' + inter.guild.name + '` - No auto-delete timer currently in place any longer for LFG Request messages.\n\n**Note:** To update the auto-delete timer in the future simply re-run `/setup`', inline=False) msg_setup_confirm.timestamp = datetime.datetime.now() msg_setup_confirm.set_footer(text=txt_footer + str(msg_setup_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_setup_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_setup_confirm, ephemeral=True) sql = "UPDATE guilds SET lfg_remove = %s WHERE guild_id = %s" val = (0, inter.guild.id) await mysql_commit(sql=sql, val=val) elif (inter.component.selected_options[0].value == 'thread_setup-disable') | (inter.component.selected_options[0].value == 'thread_setup-enable') | (inter.component.selected_options[0].value == 'banner_setup-disable') | (inter.component.selected_options[0].value == 'banner_setup-enable') | (inter.component.selected_options[0].value == 'active_setup-disable') | (inter.component.selected_options[0].value == 'active_setup-enable') | (inter.component.selected_options[0].value == 'host_setup-disable') | (inter.component.selected_options[0].value == 'host_setup-enable'): sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) options = sql_connect.fetchall() preference_dict = ast.literal_eval(options[0]['setup_options']) msgsetup = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Post Banner Preference Updated', description='Thank you for providing your input on the Server\'s preference, succesfully updated!', color=0xffffff) msgsetup.timestamp = datetime.datetime.now() msgsetup.set_footer(text=txt_footer + str(msgsetup.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msgsetup.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msgsetup.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass if inter.component.selected_options[0].value == 'banner_setup-enable': preference_dict['banner_setup'] = 'Enabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='Default banners are now **enabled** for new LFG Posts.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'banner_setup-disable': preference_dict['banner_setup'] = 'Disabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='Default banners are now **disabled** for new LFG Posts.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'thread_setup-enable': preference_dict['thread_setup'] = 'Enabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='Thread auto-creation is now **enabled** for new LFG Posts.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'thread_setup-disable': preference_dict['thread_setup'] = 'Disabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='Thread auto-creation is now **disbaled** for new LFG Posts.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'active_setup-enable': preference_dict['active_setup'] = 'Enabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='Allow users to have **multiple** LFG requests open at once.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'active_setup-disable': preference_dict['active_setup'] = 'Disabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='**Replace** a user\'s last LFG request with their new one.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'host_setup-enable': preference_dict['host_setup'] = 'Enabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='/host usage **enabled** at anytime by any user.') await inter.followup(embed=msgsetup, ephemeral=True) elif inter.component.selected_options[0].value == 'host_setup-disable': preference_dict['host_setup'] = 'Disabled' sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(preference_dict), inter.guild.id) await mysql_commit(sql=sql, val=val) msgsetup.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Updated Preference', value='/host usage **disabled**, best for if your prefer to only use /link.') await inter.followup(embed=msgsetup, ephemeral=True) elif (inter.component.selected_options[0].value == 'global_lfg-in') | (inter.component.selected_options[0].value == 'global_lfg-out') | (inter.component.selected_options[0].value == 'global_lfg-invite'): if inter.component.selected_options[0].value == 'global_lfg-invite': sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) options = sql_connect.fetchall() preference_dict = ast.literal_eval(options[0]['setup_options']) msg_invite = Embed(title='✨┃Set Internal Invite Visibility Preference', description='Show or Hide this Discord server\'s invite link, on posts for the Global LFG Network.', color=0xffffff) if preference_dict['internal_invites'] == 'Enabled': msg_invite.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Current Internal Invite Preference', value='`' + inter.guild.name + '`\'s server invite is **Visible** on posts it provides to the Global LFG Network, when Opted-In.', inline=False) else: msg_invite.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Current Internal Invite Preference', value='`' + inter.guild.name + '`\'s server invite is **Hidden** on posts it provides to the Global LFG Network, when Opted-In.', inline=False) msg_invite.add_field(name='❔┃Internal Invite Visibility Features', value='• If your Discord server is Opted-Into the Global LFG Network, you may choose to provide external users with an invite link on `/notify` or `/search` usage.\n\n• Choosing to remain **Hidden** is great if your only intention is to fill your in-game lobby, not your private Discord server.\n\n• Discord servers by default have their invites **Visibile**, assisting with boosting said server\'s growth and improving communication among players.', inline=False) msg_invite.timestamp = datetime.datetime.now() msg_invite.set_footer(text=txt_footer + str(msg_invite.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_invite.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_invite.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_invite, components=[ActionRow(sopt_setup_invite)], ephemeral=True) else: if inter.component.selected_options[0].value == 'global_lfg-in': global_lfg_pref = 'In' sql = "UPDATE guilds SET global_lfg_opt = %s WHERE guild_id = %s" val = (global_lfg_pref, inter.guild.id) await mysql_commit(sql=sql, val=val) else: global_lfg_pref = 'Out' sql = "UPDATE guilds SET global_lfg_opt = %s WHERE guild_id = %s" val = (global_lfg_pref, inter.guild.id) await mysql_commit(sql=sql, val=val) sql = "SELECT * FROM posts WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: for guild_post in sql_dict: clone_dict = guild_post['clones'] clones = {} try: clones = ast.literal_eval(clone_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) msg_confirm = Embed(title='<:check:902430116234285136>┃Discord Server\'s Global LFG Preference Updated', description='Thank you for providing your input on the Server\'s preference, succesfully updated!', color=0xffffff) msg_confirm.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated Global LFG Network Preference', value='`' + inter.guild.name + '` has now Opted-**' + global_lfg_pref + '** the Global LFG Network.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirm, ephemeral=True) elif (inter.component.selected_options[0].value == 'internal_invites-enable') | (inter.component.selected_options[0].value == 'internal_invites-disable'): sql = "SELECT setup_options FROM guilds WHERE guild_id = %s" val = (inter.guild.id,) await mysql_commit(sql=sql, val=val) internal_invites = ast.literal_eval(sql_connect.fetchone()['setup_options']) msg_confirm = Embed(title='<:check:902430116234285136>┃Discord Server\'s Internal Invite Visibility Preference Updated', description='Thank you for providing your input on the Server\'s preference, succesfully updated!', color=0xffffff) if inter.component.selected_options[0].value == 'internal_invites-enable': internal_invites.update({"internal_invites":"Enabled"}) msg_confirm.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated Internal Invite Visibility Preference', value='`' + inter.guild.name + '`\'s server invite is now **Visible** on posts it provides to the Global LFG Network, when Opted-In.', inline=False) else: internal_invites.update({"internal_invites":"Disabled"}) msg_confirm.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated Internal Invite Visibility Preference', value='`' + inter.guild.name + '`\'s server invite is now **Hidden** on posts it provides to the Global LFG Network, when Opted-In.', inline=False) sql = "UPDATE guilds SET setup_options = %s WHERE guild_id = %s" val = (str(internal_invites), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_confirm, ephemeral=True) elif (inter.component.selected_options[0].value == 'lfg_restrict-1') | (inter.component.selected_options[0].value == 'lfg_restrict-2') | (inter.component.selected_options[0].value == 'lfg_restrict-3') | (inter.component.selected_options[0].value == 'lfg_restrict-4'): response_ids_rejected = [] response_ids_vetted = [] response_accepted = '' response_rejected = '' if inter.component.selected_options[0].value == 'lfg_restrict-1': msg_restrict_1 = Embed(title='🛠️┃Setup LFG Restrictions - Option 1', description='In order to use Option 1, please respond to this message (*Max 4000 Characters*) using the format outlined below.\n\n**This will completely overwrite your current restrictions, so be sure to include current IDs as well!**', color=0xffffff) msg_restrict_1.add_field(name='❔┃Response Instructions', value='Only restrict `/host` usage to certain channel(s):\n\n• **Response Format:**\n\n`<channel_id_1>` `<channel_id_2>` `<channel_id_3>`\n\n• **Example:**\n\n`879885093777313803` `879043216530345994` `879886391213965363`\n\n**Note:** You may alternatively mention a channel using `#` instead of providing it\'s ID.', inline=False) msg_restrict_1.timestamp = datetime.datetime.now() msg_restrict_1.set_footer(text=txt_footer + str(msg_restrict_1.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_1.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_1.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict_1, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_ids_submitted = response.content[:1900].split() response_ids_submitted = list(set(response_ids_submitted)) for response_id in response_ids_submitted: if ('<#' in response_id) & ('>' in response_id): response_id = response_id.replace('<#', '').replace('>', '') if response_id.isdecimal(): if (bool([guild_channel for guild_channel in inter.guild.text_channels if (str(guild_channel.id) == str(response_id))])) & (response_id not in response_ids_vetted): response_ids_vetted.append(response_id) response_ids_vetted = list(set(response_ids_vetted)) if Counter(response_ids_vetted)[response_id] <= 1: response_accepted = response_accepted + '• <#' + str(response_id) + '>\n' else: response_ids_vetted = list(set(response_ids_vetted)) else: response_ids_rejected.append(str(response_id)) if Counter(response_ids_rejected)[response_id] <= 1: if response_id in response_ids_vetted: response_rejected = response_rejected + '• `' + str(response_id) + ' - Already accepted`\n' else: response_rejected = response_rejected + '• `' + str(response_id) + '`\n' else: response_ids_rejected = list(set(response_ids_rejected)) else: response_ids_rejected.append(str(response_id)) if Counter(response_ids_rejected)[response_id] <= 1: response_rejected = response_rejected + '• `' + str(response_id) + '`\n' else: response_ids_rejected = list(set(response_ids_rejected)) prompt_accept = 'The below ID(s) were verified to be valid channel(s) or already submiited above, `/host` use is now restricted to said channel(s):\n\n' + response_accepted prompt_reject = 'The below ID(s) were not verified to be valid channel(s), please re-copy your channel ID(s) then re-run `/setup` to re-try:\n\n' + response_rejected msg_restrict_1_update = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Restrictions Updated', description='Thank you for providing your input on the Server\'s LFG Restrictions preference, succesfully updated!', color=0xffffff) msg_restrict_1_update.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated LFG Restrictions Preference', value='`' + inter.guild.name + '` - Only restrict `/host` usage to certain channel(s).\n\n**Note:** To update restrictions in the future simply re-run `/setup`', inline=False) if bool(response_accepted): if len(prompt_accept) <= 1024: msg_restrict_1_update.add_field(name='✨┃Accepted Channel IDs', value=prompt_accept, inline=False) if bool(response_rejected): if len(prompt_reject) <= 1024: msg_restrict_1_update.add_field(name='❌┃Rejected Channel IDs', value=prompt_reject, inline=False) msg_restrict_1_update.timestamp = datetime.datetime.now() msg_restrict_1_update.set_footer(text=txt_footer + str(msg_restrict_1_update.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_1_update.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_1_update.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_restrict_1_update) if bool(response_accepted) & (len(prompt_accept) > 1024): await inter.followup(content='✨┃Accepted Channel IDs\n\n' + prompt_accept, ephemeral=True) if bool(response_rejected) & (len(prompt_reject) > 1024): await inter.followup(content='❌┃Rejected Channel IDs\n\n' + prompt_reject, ephemeral=True) if bool(response_accepted): lfg_restrictions = {"channel_ids": response_ids_vetted, "app_ids": "", "paired_restrictions": {}} sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(lfg_restrictions), inter.guild.id) await mysql_commit(sql=sql, val=val) if response_rejected == '': try: await response.delete() except: pass elif inter.component.selected_options[0].value == 'lfg_restrict-2': msg_restrict_2 = Embed(title='🛠️┃Setup LFG Restrictions - Option 2', description='In order to use Option 2, please respond to this message (*Max 4000 Characters*) using the format outlined below.\n\n**This will completely overwrite your current restrictions, so be sure to include current URLs as well!**', color=0xffffff) msg_restrict_2.add_field(name='❔┃Response Instructions', value='Only restrict `/host` usage to certain game(s):\n\n• **Response Format:**\n\n`<Game_Steam_Store_Page_URL_1>` `<Game_Steam_Store_Page_URL_2>` `<Game_Steam_Store_Page_URL_3>`\n\n• **Example:**\n\n`https://store.steampowered.com/app/281990/Stellaris/` `https://store.steampowered.com/app/1151340/Fallout_76/` `https://store.steampowered.com/app/107410/Arma_3/`', inline=False) msg_restrict_2.timestamp = datetime.datetime.now() msg_restrict_2.set_footer(text=txt_footer + str(msg_restrict_2.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_2.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_2.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict_2, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_ids_submitted = response.content[:1900].split() response_ids_submitted = list(set(response_ids_submitted)) for url in response_ids_submitted: if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response_api = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response_api: if response_api[appid]['success']: response_ids_vetted.append(appid) if Counter(response_ids_vetted)[appid] <= 1: response_accepted = response_accepted + '• [' + response_api[appid]['data']['name'] + '](' + url + ')\n' else: response_ids_vetted = list(set(response_ids_vetted)) else: response_ids_rejected.append(str(url)) if Counter(response_ids_rejected)[url] <= 1: response_rejected = response_rejected + '• `' + str(url) + '`\n' else: response_ids_rejected = list(set(response_ids_rejected)) else: response_ids_rejected.append(str(url)) if Counter(response_ids_rejected)[url] <= 1: response_rejected = response_rejected + '• `' + str(url) + '`\n' else: response_ids_rejected = list(set(response_ids_rejected)) else: response_ids_rejected.append(str(url)) if Counter(response_ids_rejected)[str(url)] <= 1: response_rejected = response_rejected + '• `' + str(url) + '`\n' else: response_ids_rejected = list(set(response_ids_rejected)) prompt_accept = 'The below URL(s) were verified to be valid Steam Store listed game(s), `/host` use is now restricted to said game(s) on this server:\n\n' + response_accepted prompt_reject = 'The below URL(s) were not verified to be valid Steam Store listed game(s), please re-copy your game URL(s) then re-run `/setup` to retry:\n\n' + response_rejected msg_restrict_2_update = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Restrictions Updated', description='Thank you for providing your input on the Server\'s LFG Restrictions preference, succesfully updated!', color=0xffffff) msg_restrict_2_update.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated LFG Restrictions Preference', value='`' + inter.guild.name + '` - Only restrict `/host` usage to certain game(s).\n\n**Note:** To update restrictions in the future simply re-run `/setup`', inline=False) if bool(response_accepted): if len(prompt_accept) <= 1024: msg_restrict_2_update.add_field(name='✨┃Accepted Store URLs', value=prompt_accept, inline=False) if bool(response_rejected): if len(prompt_reject) <= 1024: msg_restrict_2_update.add_field(name='❌┃Rejected Store URLs', value=prompt_reject, inline=False) msg_restrict_2_update.timestamp = datetime.datetime.now() msg_restrict_2_update.set_footer(text=txt_footer + str(msg_restrict_2_update.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_2_update.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_2_update.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_restrict_2_update) if bool(response_accepted) & (len(prompt_accept) > 1024): await inter.followup(content='✨┃Accepted Store URLs\n\n' + prompt_accept, ephemeral=True) if bool(response_rejected) & (len(prompt_reject) > 1024): await inter.followup(content='❌┃Rejected Store URLs\n\n' + prompt_reject, ephemeral=True) if bool(response_accepted): lfg_restrictions = {"channel_ids": "", "app_ids": response_ids_vetted, "paired_restrictions": {}} sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(lfg_restrictions), inter.guild.id) await mysql_commit(sql=sql, val=val) if response_rejected == '': try: await response.delete() except: pass elif inter.component.selected_options[0].value == 'lfg_restrict-3': msg_restrict_3 = Embed(title='🛠️┃Setup LFG Restrictions - Option 3', description='In order to use Option 3, please respond to this message (*Max 4000 Characters*) using the format outlined below.\n\n**This will completely overwrite your current restrictions, so be sure to include current IDs & URLs as well!**', color=0xffffff) msg_restrict_3.add_field(name='❔┃Response Instructions', value='Pair a restriction of channel(s) AND game(s) together:\n\n• **Response Format:**\n\n`<channel_id_1>;<Game_Steam_Store_Page_URL_1>,<Game_Steam_Store_Page_URL_2>,<Game_Steam_Store_Page_URL_3>`\n\n`<channel_id_2>;<Game_Steam_Store_Page_URL_1>,<Game_Steam_Store_Page_URL_2>,<Game_Steam_Store_Page_URL_3>`\n\n• **Example:**\n\n`879885093777313803;https://store.steampowered.com/app/281990/Stellaris/,https://store.steampowered.com/app/1151340/Fallout_76/,https://store.steampowered.com/app/107410/Arma_3/`\n\n`879043216530345994;https://store.steampowered.com/app/910490/Killsquad/,https://store.steampowered.com/app/1543030/Sword_and_Fairy_7/,https://store.steampowered.com/app/1335530/Alisa/`\n\n**Note:** You may alternatively mention a channel using `#` instead of providing it\'s ID.', inline=False) msg_restrict_3.timestamp = datetime.datetime.now() msg_restrict_3.set_footer(text=txt_footer + str(msg_restrict_3.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_3.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_3.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict_3, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_pairs_submitted = response.content[:1900].split() pair_seperated = [] pair_approved = [] pair_rejected = [] urls_rejected = [] for pair in response_pairs_submitted: if (len(pair.split(";", 1)) >= 2) and (pair.split(";", 1)[1]): pair_seperated.append(pair.split(';')) else: pair = pair.replace(';', '') pair_seperated.append([pair]) for sub_pair in pair_seperated: pair_seperated = list(dict((x[0], x) for x in pair_seperated).values()) try: sub_pair[1] except IndexError: pass else: sub_pair[1] = sub_pair[1].split(',') sub_pair[1] = list((filter(None, list(set(sub_pair[1]))))) for sub_pair in pair_seperated: urls_remove = [] if ('<#' in sub_pair[0]) & ('>' in sub_pair[0]): sub_pair[0] = sub_pair[0].replace('<#', '').replace('>', '') if (bool([item for item in inter.guild.text_channels if (str(item.id) == sub_pair[0])])) & (sub_pair not in pair_approved): try: sub_pair[1] except IndexError: pair_approved.append(sub_pair) pass else: for idx, url in enumerate(sub_pair[1]): if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response_api = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response_api: if response_api[appid]['success']: sub_pair[1][idx] = appid else: urls_remove.append(url) else: urls_remove.append(url) else: urls_remove.append(url) if urls_remove: sub_pair[1] = list(set(sub_pair[1]) - set(urls_remove)) pair_approved.append(sub_pair) else: if sub_pair in pair_approved: sub_pair[0] = sub_pair[0] + ' - Already accepted' pair_rejected.append(sub_pair) if urls_remove: urls_rejected = urls_rejected + urls_remove pairs = {} pair_dict = {} for pair in pair_approved: try: if not pair[1]: pair.remove(pair[1]) except IndexError: pass try: pair_index = pair[1] except IndexError: pair_dict_new = {pair[0]: {'app_ids': ''}} response_accepted = response_accepted + '• <#' + str(pair[0]) + '> - All games allowed\n' pass else: pair_dict_new = {pair[0]: {'app_ids': pair[1]}} titles = '' for appid in pair[1]: payload = {'appids': appid} response_api = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if appid is not pair[1][-1]: titles = titles + '[' + response_api[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: titles = titles + '[' + response_api[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' response_accepted = response_accepted + '• <#' + str(pair[0]) + '> - ' + titles + '\n' pair_dict = {**pair_dict, **pair_dict_new} pairs = {**pairs, **pair_dict} for pair in pair_rejected: try: pair[1] except IndexError: response_rejected = response_rejected + '• `' + str(pair[0]) + '`\n' pass else: titles = '' for appid in pair[1]: if appid is not pair[:-1]: titles = titles + appid + ', ' else: titles = titles + appid response_rejected = response_rejected + '• `' + str(pair[0]) + ' - ' + titles + '`\n' if urls_rejected: for url in urls_rejected: if url != ',': response_rejected = response_rejected + '• `' + url + '`\n' prompt_accept = 'The below Channel ID(s) & URL(s) were verified to be valid Server Channel(s) & Steam Store listed game(s), `/host` use is now restricted to said game(s) in said channel(s):\n\n' + response_accepted prompt_reject = 'The below Channel ID(s) & URL(s) pairs were not verified to be valid Steam Store listed game(s) and Server Channel(s), please re-copy your Channel ID(s) & game URL(s) then re-run `/setup` to retry:\n\n' + response_rejected msg_restrict_3_update = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Restrictions Updated', description='Thank you for providing your input on the Server\'s LFG Restrictions preference, succesfully updated!', color=0xffffff) msg_restrict_3_update.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated LFG Restrictions Preference', value='`' + inter.guild.name + '` - Pair a restriction of channel(s) AND game(s) together.\n\n**Note:** To update restrictions in the future simply re-run `/setup`', inline=False) if bool(response_accepted): if len(prompt_accept) <= 1024: msg_restrict_3_update.add_field(name='✨┃Accepted Channel & Game Pairs', value=prompt_accept, inline=False) if bool(response_rejected): if len(prompt_reject) <= 1024: msg_restrict_3_update.add_field(name='❌┃Rejected Channel & Game Pairs', value=prompt_reject, inline=False) msg_restrict_3_update.timestamp = datetime.datetime.now() msg_restrict_3_update.set_footer(text=txt_footer + str(msg_restrict_3_update.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_3_update.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_3_update.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(ephemeral=True, embed=msg_restrict_3_update) if bool(response_accepted) & (len(prompt_accept) > 1024): await inter.followup(content='✨┃Accepted Channel & Game Pairs\n\n' + prompt_accept, ephemeral=True) if bool(response_rejected) & (len(prompt_reject) > 1024): await inter.followup(content='❌┃Rejected Channel & Game Pairs\n\n' + prompt_reject, ephemeral=True) if bool(response_accepted): lfg_restrictions = {"channel_ids": "", "app_ids": "", "paired_restrictions": pairs} sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(lfg_restrictions), inter.guild.id) await mysql_commit(sql=sql, val=val) if response_rejected == '': try: await response.delete() except: pass elif inter.component.selected_options[0].value == 'lfg_restrict-4': lfg_restrictions = {"channel_ids": "", "app_ids": "", "paired_restrictions": {}} sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(lfg_restrictions), inter.guild.id) await mysql_commit(sql=sql, val=val) msg_restrict_4 = Embed(title='<:check:902430116234285136>┃Discord Server\'s LFG Restrictions Updated', description='Thank you for providing your input on the Server\'s LFG Restrictions preference, succesfully updated!', color=0xffffff) msg_restrict_4.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Updated LFG Restrictions Preference', value='`' + inter.guild.name + '` - No restrictions currently in place any longer for channels or games. `/host` can be used in any channel for any game going forward.\n\n**Note:** To update restrictions in the future simply re-run `/setup`', inline=False) msg_restrict_4.timestamp = datetime.datetime.now() msg_restrict_4.set_footer(text=txt_footer + str(msg_restrict_4.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_restrict_4.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_restrict_4.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_restrict_4, ephemeral=True) elif (inter.component.selected_options[0].value == 'notify_setup-modify') or (inter.component.selected_options[0].value == 'notify_setup-clear'): if inter.component.selected_options[0].value == 'notify_setup-modify': msg_setup = Embed(title='🔔┃Setup LFG Notifications', description='In order to setup notifications for specific new LFG posts, please respond to this message (*Max 4000 Characters*) using the format outlined below.\n\n**This will completely overwrite your current notifications, so be sure to include current IDs & URLs as well!**', color=0xffffff) msg_setup.add_field(name='❔┃Response Instructions', value='Provide below Discord User ID(s), Game URL(s), or pairs of both:\n\n• Game URL(s):\n`<steam_store_url_1> <steam_store_url_2>`\n• **Example:**\n`https://store.steampowered.com/app/107410/Arma_3/ https://store.steampowered.com/app/281990/Stellaris/` \n\n• User ID(s):\n`<user_id_1> <user_id_2>`\n• **Example:**\n`284839059157942274 224349699061186570` \n\n• User ID(s) & Game URL(s):\n`<user_id_1>;<steam_store_url_1>,<steam_store_url_2>`\n• **Example:** `284839059157942274;https://store.steampowered.com/app/107410/Arma_3/,https://store.steampowered.com/app/281990/Stellaris/`\n\n**Note:** You may alternatively mention a user using `@` instead of providing their ID.', inline=False) msg_setup.timestamp = datetime.datetime.now() msg_setup.set_footer(text=txt_footer + str(msg_setup.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_setup.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_setup.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_setup.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_setup.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_setup, ephemeral=True) response = await client.wait_for('message', check=lambda message: message.author == inter.author) response_msg = response response_submitted = response.content[:1900].split() response_accepted = '' response_rejected = '' invalid_ids = [] invalid_urls = [] sql_prompt = {"app_ids": [], "paired_notifications": {}} for word in response_submitted: if ('<@' in word) & ('>' in word): word = word.replace('<@', '').replace('>', '').replace('!', '') if (word.isnumeric()) & (str(word) != str(inter.author.id)): try: await client.fetch_user(int(word)) except: if word not in invalid_ids: invalid_ids.append(word) pass else: if word not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][word] = [] elif ';' in word: if len(word.split(";", 1)) >= 2 and word.split(";", 1)[1]: pair = word.split(';') if (pair[0].isnumeric()) & (str(pair[0]) != str(inter.author.id)): try: await client.fetch_user(int(pair[0])) except: if pair[0] not in invalid_ids: invalid_ids.append(pair[0]) pass else: if pair[0] not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][pair[0]] = [] sub_pair = pair[1].split(',') for url in sub_pair: if bool((validators.url(url))) & ('https://store.steampowered.com/app/'.lower() in url.lower()): appid = (url.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response: if response[appid]['success']: if appid not in sql_prompt["paired_notifications"][pair[0]]: sql_prompt["paired_notifications"][pair[0]].append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if url not in invalid_urls: invalid_urls.append(str(url)) else: if word + ' - You cannot use your own ID!' not in invalid_ids: invalid_ids.append(word + ' - You cannot use your own ID!') else: pair = word.replace(';', '') if (pair.isnumeric()) & (str(pair) != str(inter.author.id)): try: await client.fetch_user(int(pair)) except: if pair not in invalid_ids: invalid_ids.append(pair) pass else: if pair not in sql_prompt["paired_notifications"]: sql_prompt["paired_notifications"][pair] = "" else: if word not in invalid_ids: invalid_ids.append(word) elif bool((validators.url(word))) & ('https://store.steampowered.com/app/'.lower() in word.lower()): appid = (word.split('https://store.steampowered.com/app/'.lower())[1]).split('/')[0] payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if response: if response[appid]['success']: if appid not in sql_prompt["app_ids"]: sql_prompt["app_ids"].append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if appid not in invalid_urls: invalid_urls.append(str(appid)) else: if str(word) == str(inter.author.id): invalid_ids.append(word + ' - You cannot use your own ID!') elif word not in invalid_urls: invalid_urls.append(word) if invalid_ids: response_rejected = response_rejected + '**Rejected IDs:**\n' for uuid in invalid_ids: if uuid is not invalid_ids[-1]: response_rejected = response_rejected + '• `' + uuid + '`\n' else: response_rejected = response_rejected + '• `' + uuid + '`\n\n' if invalid_urls: response_rejected = response_rejected + '**Rejected URLs:**\n' for url in invalid_urls: if url is not invalid_urls[-1]: response_rejected = response_rejected + '• `' + url + '`\n' else: response_rejected = response_rejected + '• `' + url + '`\n' if sql_prompt != {"app_ids": [], "paired_notifications": {}}: sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) ids = sql_connect.fetchall() if ids: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sql_prompt), inter.author.id) await mysql_commit(sql=sql, val=val) else: sql = "INSERT INTO notifications (discord_id, subscriptions) VALUES (%s, %s)" val = (inter.author.id, str(sql_prompt)) await mysql_commit(sql=sql, val=val) if sql_prompt['app_ids']: response_accepted = response_accepted + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: response_accepted = response_accepted + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: response_accepted = response_accepted + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if response_accepted: response_accepted = response_accepted + '\n' response_accepted = response_accepted + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' response_accepted = response_accepted + '\n' + user_prompt msg_confirm = Embed(title='🔔┃LFG Notifications Updated', description='Thank you for providing your desired notification parameters, see below confirmation of accepted and rejected items.\n\n**Note:** Re-run `/notify` to update LFG Notification preferences in the future!', color=0xffffff) if len('The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted) <= 1024: msg_confirm.add_field(name='<:check:902430116234285136>┃Accepted Parameters', value='The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted, inline=False) else: await inter.followup(content='<:check:902430116234285136>┃Accepted Parameters\n\n' + 'The below ID(s) and Game(s) will now trigger a notification for you:\n\n' + response_accepted, ephemeral=True) if bool(response_rejected) & (len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) <= 1024): msg_confirm.add_field(name='❌┃Rejected Parameters', value='The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, inline=False) elif bool(response_rejected) & (len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) > 1024): await inter.followup(content='❌┃Rejected Parameters\n\n' + 'The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, ephemeral=True) msg_confirm.add_field(name='❔┃Troubleshooting Tips', value='• In order to access a user\'s Discord ID, follow this [Official Guide](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)\n• In order to access a Steam Store URL from within the Steam Client, follow this [Community Guide](https://support-mabinogi.nexon.net/hc/en-us/articles/115004524623-How-do-I-find-my-Steam-ID-) on enabling URLs within the Client.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(ephemeral=True, embed=msg_confirm) if response_rejected == '': try: await response_msg.delete() except: pass else: msg_confirm = Embed(title='❗┃LFG Notifications Not Updated', description='Please be aware all provided notification parameters were rejected as not valid Discord User IDs or Steam Store URLs. Please re-run `/notify` to update LFG Notification preferences with corrected parameters.', color=clr_error) if len('The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected) <= 1024: msg_confirm.add_field(name='❌┃Rejected Parameters', value='The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, inline=False) else: await inter.followup(content='❌┃Rejected Parameters\n\n' + 'The below provided parameters were determined to not be a valid Discord User or Steam Game:\n\n' + response_rejected, ephemeral=True) msg_confirm.add_field(name='❔┃Troubleshooting Tips', value='• In order to access a user\'s Discord ID, follow this [Official Guide](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)\n• In order to access a Steam Store URL from within the Steam Client, follow this [Community Guide](https://support-mabinogi.nexon.net/hc/en-us/articles/115004524623-How-do-I-find-my-Steam-ID-) on enabling URLs within the Client.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_confirm.set_thumbnail(url=img_error) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(ephemeral=True, embed=msg_confirm) elif inter.component.selected_options[0].value == 'notify_setup-clear': sql = "DELETE FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) msg_confirm = Embed(title='🔔┃LFG Notifications Cleared', description='You will now no longer recieve any LFG notifications for any users or games.\n\n**Note:** Re-run `/notify` to update LFG Notification preferences in the future!', color=0xffffff) msg_confirm.add_field(name='❔┃Troubleshooting Tips', value='• In order to access a user\'s Discord ID, follow this [Official Guide](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)\n• In order to access a Steam Store URL from within the Steam Client, follow this [Community Guide](https://support-mabinogi.nexon.net/hc/en-us/articles/115004524623-How-do-I-find-my-Steam-ID-) on enabling URLs within the Client.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: try: msg_confirm.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) except AttributeError: try: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass pass await inter.followup(embed=msg_confirm, ephemeral=True) else: await inter.followup(embed=msg_private, ephemeral=True) # ################ On Button Click ######################## @client.event async def on_button_click(inter: MessageInteraction): await inter.send(embed=msg_process, ephemeral=True, type=5) if inter.component.custom_id is not None: if inter.component.custom_id == 'post_close': expected_permissions = ['administrator', 'manage_messages'] if (inter.message.embeds[0].thumbnail.url.split('?uuid=')[1] == str(inter.author.id)) or bool([item for item in inter.author.guild_permissions if ((item[0] in expected_permissions) & (item[1] is True))]): await inter.followup(embed=inter.message.embeds[0], ephemeral=True) msg_remove = Embed(title='<:check:902430116234285136>┃LFG Post Removed', description='The `🗑️ Close Post` request for the above LFG Post was succesful, said post is now removed. Be sure to use `/host` to create a new LFG Post in the future!', color=0xffffff) msg_remove.timestamp = datetime.datetime.now() msg_remove.set_footer(text=txt_footer + str(msg_remove.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_remove, ephemeral=True) sql = "SELECT * FROM posts WHERE message_id = %s" val = (inter.message.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (inter.message.id,) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (inter.message.id,) await mysql_commit(sql=sql, val=val) try: await inter.message.delete() except: pass else: msg_error = Embed(title='❌┃Post Removal Forbidden', description='We apologize however, you are forbidden from removing the posts unless you are the Post\'s LFG Requestor, an Adminstrator, or have the Manage Messages permission.', color=clr_error) msg_error.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error.set_thumbnail(url=img_error) msg_error.timestamp = datetime.datetime.now() msg_error.set_footer(text=txt_error + str(msg_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error, ephemeral=True) elif inter.component.custom_id == 'thread_close': thread = inter.message.channel expected_permissions = ['administrator', 'manage_messages'] post_author_id = str(inter.message.embeds[0].thumbnail.url.split('?uuid=')[1]) if (str(inter.author.id) == post_author_id) or bool([item for item in inter.author.guild_permissions if ((item[0] in expected_permissions) & (item[1] is True))]): msg_remove = Embed(title='<:check:902430116234285136>┃LFG Thread Removed', description='The `🗑️ Close Thread` request for the Thread `' + inter.channel.name + '` was succesful, said Thread is now removed. Be sure to use `/host` to create a new LFG Post in the future!', color=0xffffff) msg_remove.timestamp = datetime.datetime.now() msg_remove.set_footer(text=txt_footer + str(msg_remove.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await inter.author.send(embed=msg_remove, delete_after=172800) except: pass for thread_member in inter.message.channel._members: if (thread_member != client.user.id) & (thread_member != inter.author.id): thread_member = await client.fetch_user(thread_member) msg_remove = Embed(title='❕┃LFG Thread Removed', description='Please be aware the Thread `' + inter.channel.name + '` that you were a current member, was just removed by <@' + str(inter.author.id) + '>.\n\nThis may be due to the Host not wishing to talk within said Thread or because they were ending their LFG Request.\n\nFeel free to search for a new game or direct join their Game if you havent already from their original LFG Request post. You can use `/host` to create a new LFG Post of your own as well!', color=0xffffff) msg_remove.timestamp = datetime.datetime.now() msg_remove.set_footer(text=txt_footer + str(msg_remove.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_remove.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass try: await thread_member.send(embed=msg_remove, delete_after=172800) except: pass try: await thread.delete() except: pass else: msg_error = Embed(title='❌┃Thread Removal Forbidden', description='We apologize however, you are forbidden from removing the Thread unless you are the Thread\'s LFG Requestor, an Adminstrator, or have the Manage Messages permission.', color=clr_error) msg_error.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_error.set_thumbnail(url=img_error) msg_error.timestamp = datetime.datetime.now() msg_error.set_footer(text=txt_error + str(msg_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_error.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) except AttributeError: msg_error.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) pass await inter.followup(embed=msg_error, ephemeral=True) elif inter.component.custom_id == 'post_karma': if not (inter.message.embeds[0].thumbnail.url.split('?uuid=')[1] == str(inter.author.id)): try: host_user = await client.fetch_user(int(inter.message.embeds[0].thumbnail.url.split('?uuid=')[1])) except: sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() msg_karma_error = Embed(title='❌┃Unable to Give Karma', description='Apologies however, the Discord account for the Host of this post has been deleted. Thus no karma can be given.', color=clr_error) if profile_prompt: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• Please first run `/register` to link your Steam Profile to Discord!', inline=False) msg_karma_error.timestamp = datetime.datetime.now() msg_karma_error.set_footer(text='For help click the message title to join our Support Discord!\nRun /karma to see the leaderboards!' + str(msg_karma_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_karma_error, ephemeral=True) pass else: sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (host_user.id,) await mysql_commit(sql=sql, val=val) host_prompt = sql_connect.fetchall() sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() if host_prompt: sql = "SELECT * FROM karma_log WHERE discord_id = %s AND message_id = %s" val = (inter.author.id, inter.message.id) await mysql_commit(sql=sql, val=val) karma_logs = sql_connect.fetchall() updated_embed = inter.message.embeds[0] footer_note_orig = updated_embed.footer.text.split('\n')[1].strip() footer_note_orig = (footer_note_orig.split('•')[0].strip()) if karma_logs: sql = "DELETE FROM karma_log WHERE discord_id = %s AND message_id = %s" val = (inter.author.id, inter.message.id) await mysql_commit(sql=sql, val=val) sql = "UPDATE profiles SET karma = karma - 1 WHERE discord_id = %s" val = (host_user.id,) await mysql_commit(sql=sql, val=val) msg_karma_success = Embed(title='<:check:902430116234285136>┃Karma Removed', description='You have removed your prior given +1 Karma for Host <@' + str(host_user.id) + '>', color=0xffffff) if profile_prompt: msg_karma_success.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`\n• <@' + str(host_user.id) + '>**\'s New Karma:** `' + str(host_prompt[0]['karma'] - 1) + '`', inline=False) else: msg_karma_success.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• Please first run `/register` to link your Steam Profile to Discord!\n• <@' + str(host_user.id) + '>**\'s New Karma:** `' + str(host_prompt[0]['karma'] - 1) + '`', inline=False) updated_embed.set_footer(text=updated_embed.footer.text.replace(footer_note_orig, footer_note_orig.replace(footer_note_orig.split()[0], str(host_prompt[0]['karma'] - 1))), icon_url=img_tip) else: appid = (re.search('steam://url/StoreAppPage/(.+?)/', inter.message.embeds[0].author.url)).group(1) sql = "INSERT INTO karma_log (discord_id, message_id, app_id, guild_id, channel_id) VALUES (%s, %s, %s, %s, %s)" val = (inter.author.id, inter.message.id, appid, inter.message.guild.id, inter.message.channel.id) await mysql_commit(sql=sql, val=val) sql = "UPDATE profiles SET karma = karma + 1 WHERE discord_id = %s" val = (host_user.id,) await mysql_commit(sql=sql, val=val) msg_karma_success = Embed(title='<:check:902430116234285136>┃Karma Given', description='You have given +1 Karma for Host <@' + str(host_user.id) + '>', color=0xffffff) if profile_prompt: msg_karma_success.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`\n• <@' + str(host_user.id) + '>**\'s New Karma:** `' + str(host_prompt[0]['karma'] + 1) + '`', inline=False) else: msg_karma_success.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• Please first run `/register` to link your Steam Profile to Discord!\n• <@' + str(host_user.id) + '>**\'s New Karma:** `' + str(host_prompt[0]['karma'] + 1) + '`', inline=False) updated_embed.set_footer(text=updated_embed.footer.text.replace(footer_note_orig, footer_note_orig.replace(footer_note_orig.split()[0], str(host_prompt[0]['karma'] + 1))), icon_url=img_tip) msg_karma_success.timestamp = datetime.datetime.now() msg_karma_success.set_footer(text='For help click the message title to join our Support Discord!\nRun /karma to see the leaderboards!' + str(msg_karma_success.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma_success.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_karma_success.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_karma_success, ephemeral=True) clone_row = ActionRow() for button in inter.message.components[0].to_dict()['components']: if button['style'] == 5: clone_row.add_button(style=ButtonStyle.link, label=button['label'], emoji=button['emoji']['name'], url=button['url']) else: clone_row.add_button(style=ButtonStyle.secondary, label=button['label'], emoji=button['emoji']['name'], custom_id=button['custom_id']) try: await inter.message.edit(embed=updated_embed, components=[clone_row]) except: pass sql = "SELECT * FROM posts WHERE message_id = %s" val = (inter.message.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: global_embed = inter.message.embeds[0] global_embed.description = clone_post.embeds[0].description if str(inter.message.guild.id) == str(clone_post.guild.id): global_embed.set_footer(text='Direct Message on Discord and Add the Host on Steam!\n' + updated_embed.footer.text.split('\n')[1].strip(), icon_url=img_tip) else: global_embed.set_footer(text='This is an external LFG Post, Add the Host on Steam!\n' + updated_embed.footer.text.split('\n')[1].strip(), icon_url=img_tip) global_embed.set_author(name=inter.message.embeds[0].author.name.replace('- LFG', '- Global LFG'), url=inter.message.embeds[0].author.url, icon_url=inter.message.embeds[0].author.icon_url) global_embed.title = '<:logo:908953639085821973>┃LFG Requestor' try: clone_row = ActionRow() for button in clone_post.components[0].to_dict()['components']: if button['style'] == 5: clone_row.add_button(style=ButtonStyle.link, label=button['label'], emoji=button['emoji']['name'], url=button['url']) else: clone_row.add_button(style=ButtonStyle.secondary, label=button['label'], emoji=button['emoji']['name'], custom_id=button['custom_id']) await clone_post.edit(embed=global_embed, components=[clone_row]) except: continue else: msg_karma_error = Embed(title='❌┃Unable to Give Karma', description='Apologies however, the Host of this post no longer has their Discord Account linked to their Steam Account. They must first re-run `/register`, as no karma can be given for now.', color=clr_error) if profile_prompt: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• Please first run `/register` to link your Steam Profile to Discord!', inline=False) msg_karma_error.timestamp = datetime.datetime.now() msg_karma_error.set_footer(text='For help click the message title to join our Support Discord!\nRun /karma to see the leaderboards!' + str(msg_karma_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_karma_error, ephemeral=True) else: sql = "SELECT * FROM profiles WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) profile_prompt = sql_connect.fetchall() msg_karma_error = Embed(title='❌┃Unable to Give Karma', description='In order to give Karma to a host, you must **NOT** be the host of said post.', color=clr_error) if profile_prompt: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• <@' + str(inter.author.id) + '>**\'s Karma:** `' + str(profile_prompt[0]['karma']) + '`', inline=False) else: msg_karma_error.add_field(name='👍🏼┃Karma System', value='Users who press `👍🏼` on your LFG Posts give +1 Karma, a form of rating:\n• Please first run `/register` to link your Steam Profile to Discord!', inline=False) msg_karma_error.timestamp = datetime.datetime.now() msg_karma_error.set_footer(text='For help click the message title to join our Support Discord!\nRun /karma to see the leaderboards!' + str(msg_karma_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_karma_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_karma_error, ephemeral=True) elif 'announce_unsub' in inter.component.custom_id: hostid_discord = inter.component.custom_id.split()[1] user_id = inter.author.id try: host_user = await client.fetch_user(int(hostid_discord)) except: host_user = '<@' + str(hostid_discord) + '>' pass else: host_user = '`' + str(host_user.name) + '`' not_subscribed = False sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) current_subs = sql_connect.fetchall() if current_subs: sub_dict = ast.literal_eval(current_subs[0]['subscriptions']) if str(hostid_discord) in sub_dict['paired_notifications'].keys(): del sub_dict['paired_notifications'][hostid_discord] if sub_dict['paired_notifications'] == {}: if not sub_dict['app_ids']: sql = "DELETE FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) else: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) else: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) embed_message_unsub = Embed(title='<:check:902430116234285136>┃Subscription Removed', description='You have succesfully **un-subscribed** from ' + str(host_user) + ' for **All Games**, you will no longer recieve `Subscriber Announcements` from them.', color=0xffffff) embed_message_unsub.add_field(name='🔔┃Re-Subscribe', value='To **re-subscribe** simply press the `🔕 Un-Subscribe` button above once more.', inline=False) embed_message_unsub.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_unsub.timestamp = datetime.datetime.now() embed_message_unsub.set_footer(text=txt_footer + str(embed_message_unsub.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await inter.followup(embed=embed_message_unsub, ephemeral=True) else: sub_dict['paired_notifications'][hostid_discord] = [] sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) not_subscribed = True else: sql = "INSERT INTO notifications (discord_id, subscriptions) VALUES (%s, %s)" val = (user_id, str({"app_ids": [], "paired_notifications": {str(hostid_discord): []}})) await mysql_commit(sql=sql, val=val) not_subscribed = True if not_subscribed: embed_message_resub = Embed(title='<:check:902430116234285136>┃Subscription Added', description='You have succesfully **subscribed** to ' + str(host_user) + ' for **All Games**, you will now begin recieving `Subscriber Announcements` from them again.', color=0xffffff) embed_message_resub.add_field(name='🔕┃Un-Subscribe', value='To **un-subscribe** simply press the `🔕 Un-Subscribe` button above once more.', inline=False) embed_message_resub.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_resub.timestamp = datetime.datetime.now() embed_message_resub.set_footer(text=txt_footer + str(embed_message_resub.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await inter.followup(embed=embed_message_resub, ephemeral=True) elif (inter.component.custom_id == 'post_notify') | ('post_notify' in inter.component.custom_id): if inter.component.custom_id == 'post_notify': appid = (re.search('steam://url/StoreAppPage/(.+?)/', inter.message.embeds[0].author.url)).group(1) hostid = str(inter.message.embeds[0].thumbnail.url.split('?uuid=')[1]) user_id = inter.author.id else: appid = inter.component.custom_id.split()[1] hostid = inter.component.custom_id.split()[2] user_id = int(inter.component.custom_id.split()[3]) if str(hostid) != str(user_id): sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) current_subs = sql_connect.fetchall() already_subbed = False if current_subs: sub_dict = ast.literal_eval(current_subs[0]['subscriptions']) if str(hostid) in sub_dict['paired_notifications'].keys(): if sub_dict['paired_notifications'][hostid]: if appid not in sub_dict['paired_notifications'][hostid]: gameids_dict = sub_dict['paired_notifications'][hostid].append(str(appid)) sub_dict['paired_notifications'][hostid] = gameids_dict else: sub_dict['paired_notifications'][hostid] = sub_dict['paired_notifications'][hostid].remove(str(appid)) already_subbed = True if not sub_dict['paired_notifications'][hostid]: del sub_dict['paired_notifications'][hostid] if sub_dict['paired_notifications'] == {}: if not sub_dict['app_ids']: sql = "DELETE FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) else: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) else: sub_dict['paired_notifications'][hostid] = [str(appid)] else: sub_dict['paired_notifications'][hostid] = [str(appid)] if sub_dict['paired_notifications'] != {}: sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sub_dict), user_id) await mysql_commit(sql=sql, val=val) else: sql = "INSERT INTO notifications (discord_id, subscriptions) VALUES (%s, %s)" val = (user_id, str({"app_ids": [], "paired_notifications": {str(hostid): [str(appid)]}})) await mysql_commit(sql=sql, val=val) payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if inter.component.custom_id == 'post_notify': button_id = 'post_notify ' + str(appid) + ' ' + str(hostid) + ' ' + str(inter.author.id) msg_subscription = Embed(title=inter.message.embeds[0].title, description=inter.message.embeds[0].description, color=0xffffff) if already_subbed: msg_subscription.add_field(name='<:check:902430116234285136>┃Subscription Removed', value='You have succesfully **un-subscribed** to <@' + str(hostid) + '> for the Game [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)!\n\nYou will no longer recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post.', inline=False) button_notify = [ActionRow(Button(style=ButtonStyle.danger, label='Re-Subscribe', emoji='🔔', custom_id=button_id))] else: msg_subscription.add_field(name='<:check:902430116234285136>┃Subscription Added', value='You have succesfully **subscribed** to <@' + str(hostid) + '> for the Game [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)!\n\nYou will now recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post.', inline=False) button_notify = [ActionRow(Button(style=ButtonStyle.secondary, label='Un-Subscribe', emoji='🔕', custom_id=button_id))] else: if already_subbed: msg_subscription = Embed(title='<:check:902430116234285136>┃Subscription Removed', description='You have succesfully **un-subscribed** to <@' + str(hostid) + '> for the Game [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)!\n\nYou will no longer recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post.', color=0xffffff) else: msg_subscription = Embed(title='<:check:902430116234285136>┃Subscription Added', description='You have succesfully **subscribed** to <@' + str(hostid) + '> for the Game [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)!\n\nYou will now recieve a Direct Message from <@' + str(client.user.id) + '> whenever the host creates a new LFG Post.', color=0xffffff) sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (user_id,) await mysql_commit(sql=sql, val=val) sql_prompt = sql_connect.fetchall() current_subscriptions = '' if sql_prompt: sql_prompt = ast.literal_eval(sql_prompt[0]['subscriptions']) if sql_prompt['app_ids']: current_subscriptions = current_subscriptions + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: current_subscriptions = current_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if current_subscriptions: current_subscriptions = current_subscriptions + '\n' current_subscriptions = current_subscriptions + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' current_subscriptions = current_subscriptions + '\n' + user_prompt if current_subscriptions: if len('You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions) <= 1024: msg_subscription.add_field(name='<:lfg:902430116402044949>┃Updated Notifications', value='You currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, inline=False) else: await inter.followup(content='<:lfg:902430116402044949>┃Updated Notifications\n\nYou currently have Notifications enabled for the below corresponding Discord User(s) and Game(s):\n\n' + current_subscriptions, ephemeral=True) else: msg_subscription.add_field(name='<:lfg:902430116402044949>┃Updated Notifications', value='You have no remaining Notifications for any Discord User(s) or Game(s). Run `/notify` to setup new Notifications!', inline=False) msg_subscription.timestamp = datetime.datetime.now() msg_subscription.set_footer(text=txt_footer + str(msg_subscription.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) if inter.component.custom_id == 'post_notify': msg_subscription.set_author(name=inter.message.embeds[0].author.name, url=inter.message.embeds[0].author.url, icon_url=inter.message.embeds[0].author.icon_url) await inter.followup(embed=msg_subscription, components=button_notify, ephemeral=True) else: msg_subscription.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) await inter.followup(embed=msg_subscription, ephemeral=True) else: msg_subscription_error = Embed(title='❌┃Unable to Subscribe', description='You are unable to subscribe to yourself for notifications of new LFG Posts!', color=clr_error) msg_subscription_error.add_field(name='❔┃Setup Notifications', value='Press the `🔔` buttton on other people\'s posts to subscribe to them for said game, or consider running `/notify` for other notifications.', inline=False) msg_subscription_error.timestamp = datetime.datetime.now() msg_subscription_error.set_footer(text=txt_footer + str(msg_subscription_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_subscription_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_subscription_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_subscription_error, ephemeral=True) elif (inter.component.custom_id == 'notify_stop') | (inter.component.custom_id == 'notify_stop_any'): sql = "SELECT * FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) sql_prompt = sql_connect.fetchall() remaining_subscriptions = '' userid = '' appid = '' unsubscribe_prompt = '' if 'See below a notification of a new LFG Post for Discord User,' in inter.message.content: if ('See below a notification of a new LFG Post for Discord User,' in inter.message.content) & ('now playing Steam Game `' in inter.message.content) & (inter.component.custom_id == 'notify_stop'): userid = str(inter.message.embeds[0].thumbnail.url.split('?uuid=')[1]) appid = (re.search('steam://url/StoreAppPage/(.+?)/', inter.message.embeds[0].author.url)).group(1) if sql_prompt: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() unsubscribe_prompt = ' Discord User <@' + userid + '>, playing Steam Game, `' + response[appid]['data']['name'] + '`' else: userid = str(inter.message.embeds[0].thumbnail.url.split('?uuid=')[1]) if sql_prompt: unsubscribe_prompt = ' Discord User <@' + userid + '>, playing any Steam Game' else: appid = (re.search('steam://url/StoreAppPage/(.+?)/', inter.message.embeds[0].author.url)).group(1) if sql_prompt: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() unsubscribe_prompt = ' Steam Game, `' + response[appid]['data']['name'] + '`' msg_confirm = Embed(title='🔔┃LFG Notifications Updated', description='See below your updated LFG Notitications.\n\n**Note:** Re-run `/notify` to update LFG Notification preferences in the future!', color=0xffffff) if sql_prompt: sql_prompt = ast.literal_eval(sql_prompt[0]['subscriptions']) unsubscribe_success = True if bool(userid) & bool(appid): try: sql_prompt['paired_notifications'][userid].remove(appid) if not sql_prompt['paired_notifications'][userid]: del sql_prompt['paired_notifications'][userid] except: unsubscribe_success = False pass elif bool(userid): try: del sql_prompt['paired_notifications'][userid] except: unsubscribe_success = False pass elif bool(appid): try: sql_prompt['app_ids'].remove(appid) except: unsubscribe_success = False pass if unsubscribe_success: msg_confirm.add_field(name='<:check:902430116234285136>┃Subscription Removed', value='We have recieved your unsubscription request, you will no longer recieve notifications for:' + unsubscribe_prompt, inline=False) else: msg_confirm.add_field(name='❕┃Subscription Already Removed', value='Hold up, you already are unsubscribed and are not recieving notifications for:' + unsubscribe_prompt, inline=False) sql = "UPDATE notifications SET subscriptions = %s WHERE discord_id = %s" val = (str(sql_prompt), inter.author.id) await mysql_commit(sql=sql, val=val) if sql_prompt['app_ids']: remaining_subscriptions = remaining_subscriptions + '**Steam Games:**\n• ' for game in sql_prompt['app_ids']: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['app_ids'][-1]: remaining_subscriptions = remaining_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: remaining_subscriptions = remaining_subscriptions + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if sql_prompt['paired_notifications']: if remaining_subscriptions: remaining_subscriptions = remaining_subscriptions + '\n' remaining_subscriptions = remaining_subscriptions + '**Discord Users with Steam Games:**' for uuid in sql_prompt['paired_notifications']: if uuid: game_prompt = '' if sql_prompt['paired_notifications'][uuid]: for game in sql_prompt['paired_notifications'][uuid]: payload = {'appids': game} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() if game is not sql_prompt['paired_notifications'][uuid][-1]: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/), ' else: game_prompt = game_prompt + '[' + response[game]['data']['name'] + '](https://store.steampowered.com/app/' + game + '/)' if game_prompt: user_prompt = '• <@' + str(uuid) + '>: ' + game_prompt else: user_prompt = '• <@' + str(uuid) + '>: **Any game**' remaining_subscriptions = remaining_subscriptions + '\n' + user_prompt if remaining_subscriptions: if len(remaining_subscriptions) <= 1024: msg_confirm.add_field(name='❔┃Remaining Subscriptions', value=remaining_subscriptions, inline=False) else: msg_confirm.add_field(name='❕┃No Remaining Notifications', value='Please note this request has now left you with no more subscribed LFG Notitifcations. Consider re-running `/notify` to sign back up if you desire.', inline=False) sql = "DELETE FROM notifications WHERE discord_id = %s" val = (inter.author.id,) await mysql_commit(sql=sql, val=val) else: msg_confirm.add_field(name='❕┃No Current Notifications', value='Please note you currently have no subscribed LFG Notitifcations thus we will disregard your unsubscription request.', inline=False) msg_confirm.timestamp = datetime.datetime.now() msg_confirm.set_footer(text=txt_footer + str(msg_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) msg_confirm.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) await inter.followup(embed=msg_confirm, ephemeral=True) if len(remaining_subscriptions) > 1024: await inter.followup(content='❔┃Remaining Subscriptions\n\n' + remaining_subscriptions, ephemeral=True) elif inter.component.custom_id == 'faq_status': try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'issue') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets_issue = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets_issue = response_tickets_issue + '> **Report ID:** ' + str(ticket['id']) + '\n> **Report Content:** ' + content + '\n> **Report Status:** ' + ticket['status'] + '\n\n' else: break sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'suggestion') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets_suggest = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets_suggest = response_tickets_suggest + '> **Suggestion ID:** ' + str(ticket['id']) + '\n> **Suggestion Content:** ' + content + '\n> **Suggestion Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='<:logo:908953639085821973>┃Open Steam LFG Service Tickets', description='See below your currently open tickets and their statuses.', color=0xffffff) if response_tickets_issue: msg_report.add_field(name='🛠️┃Open error report Tickets', value='See below the error reports you currently have open:\n\n' + response_tickets_issue[:1024], inline=False) else: msg_report.add_field(name='🛠️┃Open error report Tickets', value='Currently you have no open error report tickets.', inline=False) if response_tickets_suggest: msg_report.add_field(name='📝┃Open Suggestion Tickets', value='See below the suggestions you currently have open:\n\n' + response_tickets_suggest[:1024], inline=False) else: msg_report.add_field(name='📝┃Open Suggestion Tickets', value='Currently you have no open suggestion tickets.', inline=False) msg_report.add_field(name='❔┃Future Reports', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another error report or suggestion, any questions please contact developer <@224349699061186570>.', inline=False) msg_report.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report, ephemeral=True) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a error report we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass elif inter.component.custom_id == 'faq_report': try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'issue') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets = response_tickets + '> **Report ID:** ' + str(ticket['id']) + '\n> **Report Content:** ' + content + '\n> **Report Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='🛠️┃Submit Error Report', description='In order to log your encountered error or issue, please respond to this message using the format outlined below (Max 4000 Characters).\n\n**You are permitted to have open multiple report tickets at a time.**', color=0xffffff) if response_tickets: msg_report.add_field(name='📑┃Open Error Report Tickets', value='See below the error reports you currently have open:\n\n' + response_tickets[:1024], inline=False) else: msg_report.add_field(name='📑┃Open Error Report Tickets', value='Currently you have no open error report tickets.', inline=False) msg_report.add_field(name='❔┃Response Instructions', value='Provide below a text response, not including any files:\n• **Be precise:** Strive for one error per report. Include images, datetimes, used command/feature and, steps to reproduce.\n• **Be timely:** Report issues as soon as you encounter them, the sooner then the greater chance of it being included in the next patch!\n• **Offer continuing support:** Reports should not be a one and done situation. If able please follow up on issues you have seen not fixed yet and attempt to test them again after patches!', inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a error report we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass else: response = await client.wait_for('message', check=lambda message: message.author == inter.author) response = response.content[:1900] sql = "INSERT INTO submissions (type, content, discord_id) VALUES (%s, %s, %s)" val = ('issue', str(response), inter.author.id) await mysql_commit(sql=sql, val=val) msg_report_confirm = Embed(title='<:check:902430116234285136>┃Error Report Submitted', description='Thank you for your time in providing this valuable error report. We have now logged your issue and will begin investigating as soon as we are able. You can expect to hear back from once we have begun processing your report.', color=0xffffff) msg_report_confirm.add_field(name='❔┃Future Reports', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another error report, any questions please contact developer <@224349699061186570>.', inline=False) msg_report_confirm.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report_confirm.timestamp = datetime.datetime.now() msg_report_confirm.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report_confirm.set_footer(text=txt_footer + str(msg_report_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report_confirm) developer = await client.fetch_user(224349699061186570) await developer.send(content='❗┃Error Report Submitted\n> **Submitting User:** <@' + str(inter.author.id) + '>\n> **Report Content:** ' + response) elif inter.component.custom_id == 'faq_suggest': try: sql = "SELECT * FROM submissions WHERE discord_id = %s AND type = %s" val = (inter.author.id, 'suggestion') await mysql_commit(sql=sql, val=val) open_tickets = sql_connect.fetchall() response_tickets = '' if open_tickets: for idx, ticket in enumerate(open_tickets): if idx != 5: if len(ticket['content']) > 150: content = ticket['content'][:150] + '...' else: content = ticket['content'] response_tickets = response_tickets + '> **Suggestion ID:** ' + str(ticket['id']) + '\n> **Suggestion Content:** ' + content + '\n> **Suggestion Status:** ' + ticket['status'] + '\n\n' else: break msg_report = Embed(title='📝┃Submit Suggestion', description='In order to log your suggestion, please respond to this message using the format outlined below (Max 4000 Characters).\n\n**You are permitted to have open suggestion tickets at a time.**', color=0xffffff) if response_tickets: msg_report.add_field(name='📑┃Open Suggestion Tickets', value='See below the suggestions you currently have open:\n\n' + response_tickets[:1024], inline=False) else: msg_report.add_field(name='📑┃Open Suggestion Tickets', value='Currently you have no open suggestion tickets.', inline=False) msg_report.add_field(name='❔┃Response Instructions', value='Provide below a text response, not including any files:\n• **Be specific:** Avoid limited general comments, try to include examples.\n• **Be realistic:** Feedback should focus on what can be reasonably achieved.\n• **Be timely:** Being prompt is key since feedback loses its impact if delayed too long.\n• **Balance the content:** Begin by providing comments on specific strengths. Then identify specific areas of improvement and ways to make changes.\n• **Offer continuing support:** Feedback should be a continuous process, not a one-time event. After offering feedback, make a conscious effort to follow up.', inline=False) msg_report.timestamp = datetime.datetime.now() msg_report.set_image(url='https://media4.giphy.com/media/ZF8GoFOeBDwHFsVYqt/giphy.gif?cid=ecf05e47ren3clsuawrqv7zttx33laf3tj5fqkewbmfneysj&rid=giphy.gif&ct=g') msg_report.set_footer(text=txt_footer + str(msg_report.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report) except: msg_report_error = Embed(title='❌┃Direct Messages Disabled', description='In order to submit a suggestion we must be able to Direct Message you a desired format. Please first open your settings to allow Direct Messages from server members, then try again.', color=clr_error) msg_report_error.timestamp = datetime.datetime.now() msg_report_error.set_footer(text=txt_footer + str(msg_report_error.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_error.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.followup(embed=msg_report_error, ephemeral=True) pass else: response = await client.wait_for('message', check=lambda message: message.author == inter.author) response = response.content[:1900] sql = "INSERT INTO submissions (type, content, discord_id, status) VALUES (%s, %s, %s, %s)" val = ('suggestion', str(response), inter.author.id, 'Pending Review') await mysql_commit(sql=sql, val=val) msg_report_confirm = Embed(title='<:check:902430116234285136>┃Suggestion Submitted', description='Thank you for your time in providing this valuable feedback. We have now logged your suggestion and will review it as soon as we are able. You can expect to hear back from once we have begun processing your ticket.', color=0xffffff) msg_report_confirm.add_field(name='❔┃Future Suggestions', value='Feel free to visit tour **[Support Server](https://discord.gg/8DE5z5tTY8)** at anytime in order to submit another suggestion, any questions please contact developer <@224349699061186570>.', inline=False) msg_report_confirm.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) msg_report_confirm.timestamp = datetime.datetime.now() msg_report_confirm.set_image(url='https://media1.giphy.com/media/fdLR6LGwAiVNhGQNvf/giphy.gif?cid=ecf05e479yrb09kxk96z4ykbxctrtz550425w74iqsg4u0d5&rid=giphy.gif&ct=g') msg_report_confirm.set_footer(text=txt_footer + str(msg_report_confirm.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) except AttributeError: msg_report_confirm.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) pass pass await inter.author.send(embed=msg_report_confirm) developer = await client.fetch_user(224349699061186570) await developer.send(content='❕┃Suggestion Submitted\n> **Submitting User:** <@' + str(inter.author.id) + '>\n> **Suggestion Content:** ' + response) else: await inter.followup(embed=msg_private) # ################ On Text Channel Delete ######################## @client.event async def on_guild_channel_delete(channel): sql = "SELECT lfg_restrictions FROM guilds WHERE guild_id = %s" val = (channel.guild.id,) await mysql_commit(sql=sql, val=val) restrictions = sql_connect.fetchall() sql = "SELECT notifications FROM notifications WHERE guild_id = %s" val = (channel.guild.id,) await mysql_commit(sql=sql, val=val) subscriptions_dict = sql_connect.fetchone() if subscriptions_dict: subscriptions_dict = ast.literal_eval(subscriptions_dict['notifications']) if str(channel.id) in subscriptions_dict: del subscriptions_dict[str(channel.id)] sql = "UPDATE notifications SET notifications = %s WHERE guild_id = %s" val = (str(subscriptions_dict), channel.guild.id) await mysql_commit(sql=sql, val=val) prompt_notifications = '' msg_remainder = Embed(title='❌┃Registered Notifications Channel Deleted', description='We apologize however it seems you have just deleted a channel being used for Global LFG Post Notifications.', color=clr_error) if subscriptions_dict: for channelid, appids in subscriptions_dict.items(): if bool([guild_channel for guild_channel in channel.guild.text_channels if (str(guild_channel.id) == str(channelid))]): if appids: prompt_notifications = prompt_notifications + '• <#' + channelid + '>:' for app_id_dict in appids: app_id = list(app_id_dict.keys())[0] payload = {'appids': app_id} response = ( requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() userids = app_id_dict[app_id] users_prompt = '[**Hosts:** ' if userids: for user_id in userids: try: user = await client.fetch_user(int(user_id)) except: try: guild = await client.fetch_guild(int(user_id)) except: if user_id != userids[-1]: users_prompt = users_prompt + '`Invalid User/Server: **' + user_id + '**`, ' else: users_prompt = users_prompt + '`Invalid User/Server: **' + user_id + '**`' pass else: if user_id != userids[-1]: users_prompt = users_prompt + '`' + guild.name + '`, ' else: users_prompt = users_prompt + '`' + guild.name + '`' pass else: if user_id != userids[-1]: users_prompt = users_prompt + '<@' + user_id + '>, ' else: users_prompt = users_prompt + '<@' + user_id + '>' try: response[app_id]['data'] except KeyError: if app_id_dict != appids[-1]: if userids: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + '],' else: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/),' else: if userids: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + ']\n' else: prompt_notifications = prompt_notifications + ' [Invalid Game (*Possibly Removed from Steam Store*)](https://store.steampowered.com/app/' + app_id + '/)\n' pass else: if app_id_dict != appids[-1]: if userids: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + '],' else: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/),' else: if userids: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)' + users_prompt + ']\n' else: prompt_notifications = prompt_notifications + ' [' + response[app_id]['data']['name'] + '](https://store.steampowered.com/app/' + app_id + '/)\n' else: prompt_notifications = prompt_notifications + '• <#' + channelid + '>' + ' - Notifications enabled for new LFG Posts regardless of game.' else: prompt_notifications = prompt_notifications + '• ' + channelid + ' - Invalid Channel ID (*Possibly Deleted from Server*) ' msg_remainder.add_field(name='❔┃What to do', value='In order to continue Channel Notifications for Global LFG Posts in said manner that said channel was setup, please consider re-running `/setup`.\n\nThe deleted Channel was named `' + channel.name + '`, however note there are still other channels active for Global LFG Notifications, meaning users will continue to see Global LFG Posts according to the configurations of each remaining channel.', inline=False) else: prompt_notifications = 'No Channel Notifications remain any longer for your server.' msg_remainder.add_field(name='❔┃What to do', value='In order to continue Channel Notifications services for Global LFG Posts please immediately re-run `/setup`.\n\nThe deleted Channel named `' + channel.name + '` was your only channel for Notifications which means users can will no longer see Global LFG Posts anywhere now.', inline=False) sql = "DELETE FROM notifications WHERE guild_id = %s" val = (channel.guild.id,) await mysql_commit(sql=sql, val=val) if len(prompt_notifications) <= 1024: msg_remainder.add_field(name='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences', value=prompt_notifications) try: await channel.guild.owner.send(embed=msg_remainder) if len(prompt_notifications) > 1024: await channel.guild.owner.send(content='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences\n' + prompt_notifications) except: await channel.guild.system_channel.send(embed=msg_remainder) if len(prompt_notifications) > 1024: await channel.guild.system_channel.send(content='<:lfg:902430116402044949>┃Discord Server\'s Current Channel Notification Preferences\n' + prompt_notifications) pass sql = "SELECT * FROM posts WHERE channel_id = %s" val = (channel.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: for guild_post in sql_dict: clone_dict = guild_post['clones'] clones = {} try: clones = ast.literal_eval(clone_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE channel_id = %s" val = (channel.id,) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE channel_id = %s" val = (channel.id,) await mysql_commit(sql=sql, val=val) found = False restrictions_dict = ast.literal_eval(restrictions[0]['lfg_restrictions']) if restrictions_dict['channel_ids']: for idx, channel_id in enumerate(restrictions_dict['channel_ids']): if str(channel.id) == str(channel_id): if len(restrictions_dict['channel_ids']) == 1: msg_alert = Embed(title='❌┃Only Registered LFG Channel Deleted', description='We apologize however it seems you have just deleted the **only channel being used for LFG Restrictions**.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue restricting services for `/host` please immediately re-run `/setup`.\n\nThe deleted Channel named `' + channel.name + '` was your only channel for LFG\'ing which means users can use `/host` anywhere now and are no longer restricted to said channel.', inline=False) restrictions_dict['channel_ids'].remove(channel_id) restrictions_dict['channel_ids'] = '' if len(restrictions_dict['channel_ids']) > 1: msg_alert = Embed(title='❌┃Registered LFG Channel Deleted', description='We apologize however it seems you have just deleted a channel being used for LFG Restrictions.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue restricting services for `/host` in said manner that said channel was setup, please consider re-running `/setup`.\n\nThe deleted Channel was named `' + channel.name + '`, however note there are still other LFG channels active meaning `/host` will continue to be restricted to said channels.', inline=False) restrictions_dict['channel_ids'].remove(channel_id) sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(restrictions_dict), channel.guild.id) await mysql_commit(sql=sql, val=val) found = True break elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: if str(channel.id) == str(channel_id): if len(restrictions_dict['paired_restrictions']) == 1: msg_alert = Embed(title='❌┃Only Registered Paired LFG Channel Deleted', description='We apologize however it seems you have just deleted the **only channel being used for Paired LFG Restrictions**.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue restricting services for `/host` please immediately re-run `/setup`.\n\nThe deleted Channel named `' + channel.name + '` was your only channel for LFG\'ing which means users can use `/host` anywhere now and are no longer restricted to said channel.', inline=False) del restrictions_dict['paired_restrictions'][channel_id] restrictions_dict['paired_restrictions'] = {} if len(restrictions_dict['paired_restrictions']) > 1: msg_alert = Embed(title='❌┃Registered Paired LFG Channel Deleted', description='We apologize however it seems you have just deleted a channel being used for Paired LFG Restrictions.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue restricting services for `/host` in said manner that said channel was setup, please consider re-running `/setup`.\n\nThe deleted Channel was named `' + channel.name + '`, however note there are still other LFG channels active meaning `/host` will continue to be restricted to said channels.', inline=False) del restrictions_dict['paired_restrictions'][channel_id] sql = "UPDATE guilds SET lfg_restrictions = %s WHERE guild_id = %s" val = (str(restrictions_dict), channel.guild.id) await mysql_commit(sql=sql, val=val) found = True break if found: sql = "SELECT lfg_restrictions FROM guilds WHERE guild_id = %s" val = (channel.guild.id,) await mysql_commit(sql=sql, val=val) restrictions = sql_connect.fetchall() restrictions_dict = ast.literal_eval(restrictions[0]['lfg_restrictions']) lfg_restrictions = '' if restrictions_dict['channel_ids']: for channel_id in restrictions_dict['channel_ids']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - All games allowed\n' elif restrictions_dict['app_ids']: for appid in restrictions_dict['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: lfg_restrictions = lfg_restrictions + '• Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/\n' pass else: lfg_restrictions = lfg_restrictions + '• [' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/)\n' elif restrictions_dict['paired_restrictions']: for channel_id in restrictions_dict['paired_restrictions']: lfg_restrictions = lfg_restrictions + '• <#' + str(channel_id) + '> - ' if restrictions_dict['paired_restrictions'][channel_id]['app_ids']: for appid in restrictions_dict['paired_restrictions'][channel_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_restrictions = lfg_restrictions + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not restrictions_dict['paired_restrictions'][channel_id]['app_ids'][-1]: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_restrictions = lfg_restrictions + ' [' + response[appid]['data'][ 'name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_restrictions = lfg_restrictions + 'All games allowed' lfg_restrictions = lfg_restrictions + '\n' else: lfg_restrictions = '• Restrictions **no longer in place** for any channels or games. `/host` can be used in any channel for any game.' prompt_restrictions = '`' + channel.guild.name + '` Restrictions: \n\n' + lfg_restrictions if len(prompt_restrictions) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences', value=prompt_restrictions, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=channel.guild.name, url=url_discord, icon_url=channel.guild.icon.url) except AttributeError: msg_alert.set_author(name=channel.guild.name, url=url_discord, icon_url=img_unknown) pass try: await channel.guild.owner.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await channel.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) except: await channel.guild.system_channel.send(embed=msg_alert) if len(prompt_restrictions) > 1024: await channel.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Restrictions Preferences\n\n' + prompt_restrictions) pass # ################ On Invite Delete ######################## @client.event async def on_invite_delete(invite): sql = "SELECT * FROM guilds WHERE guild_id = %s" val = (invite.guild.id,) await mysql_commit(sql=sql, val=val) invite_checks = sql_connect.fetchall() if invite_checks[0]['global_lfg_opt'] == 'In': try: await client.fetch_invite(str(invite_checks[0]['global_lfg_invite'])) except errors.NotFound: try: text_channel = random.choice(invite.guild.text_channels) global_lfg_invite = await text_channel.create_invite(max_uses=0, max_age=0, unique=True) sql = "UPDATE guilds SET global_lfg_invite = %s WHERE guild_id = %s" val = (str(global_lfg_invite), invite.guild.id) await mysql_commit(sql=sql, val=val) except: pass pass # ################ On Text Channel Delete ######################## @client.event async def on_guild_role_delete(role): sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (role.guild.id,) await mysql_commit(sql=sql, val=val) lfg_roles = sql_connect.fetchall() found = False roles_dict = ast.literal_eval(lfg_roles[0]['lfg_roles']) if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: if str(role.id) == str(role_id): if len(roles_dict['paired_roles']) == 1: msg_alert = Embed(title='❌┃Only Setup Role for LFG Pings Deleted', description='We apologize however it seems you have just deleted the **only role being used for automatic LFG Pings**.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue automatically pinging roles on `/host` usage, please consider re-running `/setup`.\n\nThe deleted Role named `' + role.name + '` was your only role for LFG Role Pings which means users with said old role will no longer be pinged on `/host` usage any longer for paired games.', inline=False) del roles_dict['paired_roles'][role_id] roles_dict['paired_roles'] = {} if len(roles_dict['paired_roles']) > 1: msg_alert = Embed(title='❌┃Registered Role for LFG Pings Deleted', description='We apologize however it seems you have just deleted a role being used for automatic LFG Pings.', color=clr_error) msg_alert.add_field(name='❔┃What to do', value='In order to continue automatically pinging roles on `/host` usage, please consider re-running `/setup`.\n\nThe deleted Role was named `' + role.name + '`, however note there are still other pairs of LFG Role Pings active meaning `/host` will continue to automatically ping users for remaining paired games.', inline=False) del roles_dict['paired_roles'][role_id] sql = "UPDATE guilds SET lfg_roles = %s WHERE guild_id = %s" val = (str(roles_dict), role.guild.id) await mysql_commit(sql=sql, val=val) found = True break if found: sql = "SELECT lfg_roles FROM guilds WHERE guild_id = %s" val = (role.guild.id,) await mysql_commit(sql=sql, val=val) roles = sql_connect.fetchall() lfg_roles = '' roles_dict = ast.literal_eval(roles[0]['lfg_roles']) if roles_dict['paired_roles']: for role_id in roles_dict['paired_roles']: try: guild_role = role.guild.get_role(int(role_id)) except: lfg_roles = lfg_roles + '• `Role ID: ' + str(role_id) + '` - ' continue else: lfg_roles = lfg_roles + '• `' + str(guild_role.name) + '` - ' if roles_dict['paired_roles'][role_id]['app_ids']: for appid in roles_dict['paired_roles'][role_id]['app_ids']: payload = {'appids': appid} response = (requests.get('http://store.steampowered.com/api/appdetails', params=payload)).json() try: response[appid]['data'] except KeyError: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/, ' else: lfg_roles = lfg_roles + ' Invalid Game (*Possibly Removed from Steam Store*) - https://store.steampowered.com/app/' + appid + '/' pass else: if appid is not roles_dict['paired_roles'][role_id]['app_ids'][-1]: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/), ' else: lfg_roles = lfg_roles + ' [' + response[appid]['data']['name'] + '](https://store.steampowered.com/app/' + appid + '/)' else: lfg_roles = lfg_roles + 'Will be pinged on `/host` usage for all games' lfg_roles = lfg_roles + '\n' else: lfg_roles = '• No role pings currently in place any longer for games.\n\n**Note:** To update role pings in the future simply re-run `/setup`' prompt_roles = '`' + role.guild.name + '` LFG Role Pings: \n\n' + lfg_roles if len(prompt_roles) <= 1024: msg_alert.add_field(name='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences', value=prompt_roles, inline=False) msg_alert.set_thumbnail(url=img_error) msg_alert.timestamp = datetime.datetime.now() msg_alert.set_footer(text=txt_footer + str(msg_alert.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: msg_alert.set_author(name=role.guild.name, url=url_discord, icon_url=role.guild.icon.url) except AttributeError: msg_alert.set_author(name=role.guild.name, url=url_discord, icon_url=img_unknown) pass try: await role.guild.owner.send(embed=msg_alert) if len(prompt_roles) > 1024: await role.guild.owner.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) except: await role.guild.system_channel.send(embed=msg_alert) if len(prompt_roles) > 1024: await role.guild.system_channel.send(content='<:combine:902429705100214282>┃Discord Server\'s Remaining LFG Role Ping Preferences\n\n' + prompt_roles) pass # ################ On Message Delete ######################## @client.event async def on_message_delete(message): try: message.guild except AttributeError: pass else: if message.author.id == client.user.id: try: embeds = message.embeds[0] except: pass else: if message.embeds[0].title == '<:lfg:902430116402044949>┃LFG Requestor': sql = "SELECT * FROM posts WHERE message_id = %s" val = (message.id,) await mysql_commit(sql=sql, val=val) sql_dict = sql_connect.fetchall() if sql_dict: sql_dict = sql_dict[0]['clones'] clones = {} try: clones = ast.literal_eval(sql_dict) except: pass if clones: for channel_id, clone_id in clones.items(): try: channel = client.get_channel(int(channel_id)) clone_post = await channel.fetch_message(int(clone_id)) except: continue else: try: await clone_post.delete() except: continue sql = "DELETE FROM posts WHERE message_id = %s" val = (message.id,) await mysql_commit(sql=sql, val=val) sql = "DELETE FROM karma_log WHERE message_id = %s" val = (message.id,) await mysql_commit(sql=sql, val=val) @client.event async def on_message(ctx): if ctx.webhook_id is None: if (ctx.channel.type is ChannelType.private) & (ctx.author.id == 224349699061186570) & ('!help' in ctx.content): embed_message_help = Embed(title=client.user.display_name + ' - Hidden Commands', description='See below a list of hidden commands restricted to user <@224349699061186570>.', color=0xffffff) embed_message_help.add_field(name="💬┃Server Owner Announcement:", value='Usage: `!announce optional(int(guild_id)) message`', inline=False) embed_message_help.add_field(name="🛑┃Leave Joined Servers:", value='Usage: `!leave int(guild_id) silent/inform`', inline=False) embed_message_help.timestamp = datetime.datetime.now() embed_message_help.set_footer(text=txt_footer + str(embed_message_help.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_help, delete_after=30) elif (ctx.channel.type is ChannelType.private) & (ctx.author.id == 224349699061186570) & ('!leave' in ctx.content): cmd_list = ctx.content.split() if len(cmd_list) == 3: if (len(cmd_list) == 3) & ((cmd_list[1].isnumeric()) | (cmd_list[1] == '*')) & ((cmd_list[2] == 'silent') | (cmd_list[2] == 'inform')): guilds = [] guild_id = 0 if cmd_list[1].isnumeric(): guild_id = int(cmd_list[1]) sql = "SELECT guild_id FROM guilds WHERE guild_id = %s" val = (str(guild_id),) await mysql_commit(sql=sql, val=val) guilds = sql_connect.fetchall() elif cmd_list[1] == '*': sql_connect.execute('SELECT guild_id FROM guilds') guilds = sql_connect.fetchall() if guilds: if guilds[0]['guild_id'] == str(guild_id): guild = utils.get(client.guilds, id=guild_id) if cmd_list[2] == 'silent': embed_message_garrus = Embed(title='❗┃Server Removal Notice', description='• Please be aware Bot `' + client.user.name + '` has left Server `' + guild.name + '` per your request.\n• Guild Owners have has been informed to re-invite the bot as soon as they are able.', color=0xffffff) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) print(f'{client.user.name} has left Guild per silent request: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) await guild.leave() sql = "DELETE FROM guilds WHERE guild_id = %s" val = (str(guild_id),) await mysql_commit(sql=sql, val=val) elif cmd_list[2] == 'inform': sql_connect.execute("SELECT * FROM guilds_announcement_blacklist") blacklisted_guilds = sql_connect.fetchall() if not bool([item for item in blacklisted_guilds if (item['guild_id'] == str(guild.id))]): button_invite = [ActionRow(Button(style=ButtonStyle.link, label='Re-Invite Bot', emoji='🤖', url=os.environ['INVITE_LINK']))] embed_message_owner = Embed(title='❗┃Server Removal Notice', description='• Please be aware Bot `' + client.user.name + '` has left your Server `' + guild.name + '`\n• These leaves occur when our Bot has recieved a substantial update requiring it to leave in order for said features to become available.\n• Please re-invite the Bot back to your server using the below link as soon as possible.', color=clr_error) try: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=guild.icon.url) except AttributeError: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_owner.timestamp = datetime.datetime.now() embed_message_owner.set_footer(text=txt_footer + str(embed_message_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) embed_message_owner.set_thumbnail(url=img_error) try: await guild.owner.send(embed=embed_message_owner, components=button_invite) except: pass elif bool([item for item in blacklisted_guilds if (item['guild_id'] == str(guild.id))]): print(f'{client.user.name} skipped informing blacklisted guild \'' + str(guild.name) + '\' @ ' + str(datetime.datetime.now())) embed_message_garrus = Embed(title='❗┃Server Removal Notice', description='• Please be aware Bot `' + client.user.name + '` has left Server `' + guild.name + '` per your request.\n• Guild Owner <@' + str(guild.owner.id) + '> has been informed to re-invite the bot as soon as they are able.', color=0xffffff) try: embed_message_garrus.set_author(name=guild.name, url=url_discord, icon_url=guild.icon.url) except AttributeError: embed_message_garrus.set_author(name=guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) print(f'{client.user.name} has left Guild per inform request: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) await guild.leave() sql = "DELETE FROM guilds WHERE guild_id = %s" val = (str(guild_id),) await mysql_commit(sql=sql, val=val) elif cmd_list[1] == '*': embed_message_garrus = Embed(title='❗┃Server Removal Notice', description='• Please be aware Bot `' + client.user.name + '` has left all Servers per your request.\n• Guild Owners have has been informed to re-invite the bot as soon as they are able.', color=0xffffff) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) for guild in client.guilds: if cmd_list[2] == 'silent': print(f'{client.user.name} has left Guild per silent request: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) sql = "DELETE FROM guilds WHERE guild_id = %s" val = (str(guild.id),) await mysql_commit(sql=sql, val=val) await guild.leave() elif cmd_list[2] == 'inform': button_invite = [ActionRow(Button(style=ButtonStyle.link, label='Re-Invite Bot', emoji='🤖', url=os.environ['INVITE_LINK']))] embed_message_owner = Embed(title='❗┃Server Removal Notice', description='• Please be aware Bot `' + client.user.name + '` has left your Server `' + guild.name + '`\n• These leaves occur when our Bot has recieved a substantial update requiring it to leave in order for said features to become available.\n• Please re-invite the Bot back to your server using the below link as soon as possible.', color=clr_error) try: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=guild.icon.url) except AttributeError: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_owner.timestamp = datetime.datetime.now() embed_message_owner.set_footer(text=txt_footer + str(embed_message_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) embed_message_owner.set_thumbnail(url=img_error) try: await guild.owner.send(embed=embed_message_owner, components=button_invite) except: pass print(f'{client.user.name} has left Guild per inform request: ' + str(guild.name) + ' @ ' + str(datetime.datetime.now())) sql = "DELETE FROM guilds WHERE guild_id = %s" val = (str(guild.id),) await mysql_commit(sql=sql, val=val) await guild.leave() else: await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nGuild ID provided not of any guild `' + client.user.name + '` is apart of, correct format `!leave int(guild_id) silent/inform`', delete_after=180) elif (len(cmd_list) == 3) & (not((cmd_list[1].isnumeric()) | (cmd_list[1] == '*'))) & ((cmd_list[2] == 'silent') | (cmd_list[2] == 'inform')): await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nSecond Arguement provided invalid format, not numeric, correct format `!leave int(guild_id) silent/inform`', delete_after=180) elif (len(cmd_list) == 3) & ((cmd_list[1].isnumeric()) | (cmd_list[1] == '*')) & (not ((cmd_list[2] == 'silent') | (cmd_list[2] == 'inform'))): await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nThird Arguement provided invalid format, not `silent` or `inform`, correct format `!leave int(guild_id) silent/inform`', delete_after=180) elif (len(cmd_list) == 3) & (not((cmd_list[1].isnumeric()) | (cmd_list[1] == '*'))) & (not ((cmd_list[2] == 'silent') | (cmd_list[2] == 'inform'))): await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nSecond Arguement provided invalid format, not numeric\nThird Arguement provided invalid format, not `silent` or `inform`\nCorrect format `!leave int(guild_id) silent/inform`', delete_after=180) elif len(cmd_list) > 3: await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nMore than 3 arguements provided, correct format `!leave int(guild_id) silent/inform`', delete_after=180) elif len(cmd_list) < 3: await ctx.channel.send(content='❗┃**Guild Remove - Error**:\nLess than 3 arguements provided, correct format `!leave int(guild_id) silent/inform`', delete_after=180) elif (isinstance(ctx.channel, discord.channel.DMChannel)) & (ctx.author.id == 224349699061186570) & ('!announce' in ctx.content): button_invite = [ActionRow(Button(style=ButtonStyle.link, label='Support Server', emoji='🔧', url=url_discord), Button(style=ButtonStyle.link, label='Bot Invite Link', emoji='🤖', url=os.environ['INVITE_LINK']), Button(style=ButtonStyle.link, label='Website', emoji='🌐', url=url_website))] button_channel = [ActionRow(Button(style=ButtonStyle.link, label='Service Wiki', emoji='🌐', url=url_website))] cmd_list = ctx.content.split() if len(cmd_list) >= 2: if len(cmd_list) >= 3: announce_content = '' provided_id = cmd_list[1].split(';')[0] if len(cmd_list[1].split(';')) > 1: announce_content = cmd_list[1].split(';')[1] announcement = ctx.content.replace(cmd_list[0], '').replace(cmd_list[1], '') specific_guild = client.get_guild(int(provided_id)) specific_channel = client.get_channel(int(provided_id)) announcement_delivered = False if specific_guild or specific_channel: if specific_guild: embed_message_owner = Embed(title='❕┃Developer Announcement', description='Please be aware Bot <@' + str(client.user.id) + '> has delivered an Announcement from it\'s Developer `Garrus Valkyrin` below to you personally:', color=0xffffff) embed_message_owner.add_field(name="Announcement:", value=announcement, inline=False) embed_message_owner.add_field(name="Looking to get more engaged?", value='Do you have a innovative or even a quality of life change you\'d like to see implemented? Join our Support Server today to provide us with any and all feedback in time for the next update!\n- **Rock On** :wink: - `Developer, Garrus Valkyrin#9816`', inline=False) embed_message_owner.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: embed_message_owner.set_author(name=specific_guild.name, url=url_discord, icon_url=specific_guild.icon.url) except AttributeError: embed_message_owner.set_author(name=specific_guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_owner.timestamp = datetime.datetime.now() embed_message_owner.set_footer(text=txt_footer + str(embed_message_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: await specific_guild.owner.send(embed=embed_message_owner, components=button_invite) except: embed_message_garrus = Embed(title='❕┃Developer Announcement Failed', description='Please be aware Bot `' + client.user.name + '` was unable to fetch the specific guild/channel using the provided ID:', color=clr_error) embed_message_garrus.add_field(name="Announcement:", value='`' + announcement[:1020] + '`', inline=False) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) pass else: announcement_delivered = True print(f'{client.user.name} has dispersed requested announcement to the specific Guild ' + ' @ ' + str(datetime.datetime.now())) elif specific_channel: embed_message_channel = Embed(title='❕┃Developer Announcement', description='Please be aware Bot <@' + str(client.user.id) + '> has delivered an Announcement from it\'s Developer <@224349699061186570> below:', color=0xffffff) embed_message_channel.add_field(name="Announcement:", value=announcement, inline=False) embed_message_channel.add_field(name="Looking to get more engaged?", value='• Sign up for host notifications by right-clicking a user and selecting `🔔┃Subscribe`\n• Consider hosting your own match anytime by running `/host`\n• View the host karma leaderboard by typing `/karma`', inline=False) embed_message_channel.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: embed_message_channel.set_author(name=specific_channel.guild.name, url=url_discord, icon_url=specific_channel.guild.icon.url) except AttributeError: embed_message_channel.set_author(name=specific_channel.guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_channel.timestamp = datetime.datetime.now() embed_message_channel.set_footer(text=txt_footer + str(embed_message_channel.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: if announce_content: await specific_channel.send(content='<@&' + announce_content + '>', embed=embed_message_channel, components=button_channel) else: await specific_channel.send(embed=embed_message_channel, components=button_channel) except: embed_message_garrus = Embed(title='❕┃Developer Announcement Failed', description='Please be aware Bot `' + client.user.name + '` was unable to fetch the specific guild/channel using the provided ID:', color=clr_error) embed_message_garrus.add_field(name="Announcement:", value='`' + announcement[:1020] + '`', inline=False) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) pass else: announcement_delivered = True print(f'{client.user.name} has dispersed requested announcement to the specific Channel ' + ' @ ' + str(datetime.datetime.now())) if announcement_delivered: embed_message_garrus = Embed(title='❕┃Developer Announcement Delivered', description='Please be aware Bot `' + client.user.name + '` has delivered the requested announcement to the specific guild/channel:', color=0xffffff) embed_message_garrus.add_field(name="Announcement:", value=announcement, inline=False) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) else: embed_message_garrus = Embed(title='❕┃Developer Announcement Failed', description='Please be aware Bot `' + client.user.name + '` was unable to fetch the specific guild/channel using the provided ID:', color=clr_error) embed_message_garrus.add_field(name="Announcement:", value='`' + announcement[:1020] + '`', inline=False) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) else: announcement = ctx.content.replace('!announce', '') database.commit() sql_connect.execute("SELECT * FROM guilds_announcement_blacklist") blacklisted_guilds = sql_connect.fetchall() for guild in client.guilds: if not bool([item for item in blacklisted_guilds if (item['guild_id'] == str(guild.id))]): embed_message_owner = Embed(title='❕┃Developer Announcement', description='Please be aware Bot <@' + str(client.user.id) + '> is delivering an **Announcement** from it\'s Developer `Garrus Valkyrin` below:', color=0xffffff) embed_message_owner.add_field(name="Announcement:", value=announcement, inline=False) embed_message_owner.add_field(name="How to update?", value='Nothing, updates roll out automatically! In order for the detailed new features to take place please give the bot a few minutes to process all servers, some features such as new slash commands may require up to an hour to finish implementing.', inline=False) embed_message_owner.add_field(name="Looking to get more engaged?", value='Do you have a innovative or even a quality of life change you\'d like to see implemented? Join our Support Server today to provide us with any and all feedback in time for the next update!\n- **Rock On** :wink: - `Developer, Garrus Valkyrin#9816`', inline=False) embed_message_owner.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=guild.icon.url) except AttributeError: embed_message_owner.set_author(name=guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_owner.timestamp = datetime.datetime.now() embed_message_owner.set_footer(text=txt_footer + str(embed_message_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: await guild.owner.send(embed=embed_message_owner, components=button_invite) except: pass elif bool([item for item in blacklisted_guilds if (item['guild_id'] == str(guild.id))]): print(f'{client.user.name} skipped blacklisted guild \'' + str(guild.name) + '\' @ ' + str(datetime.datetime.now())) announce_channel = client.get_channel(912166364905623593) embed_message_support = Embed(title='<:logo:908953639085821973>┃Steam LFG Service Update', description='Please be aware Bot <@' + str(client.user.id) + '> is delivering an **Update** from it\'s Developer `Garrus Valkyrin` below:', color=0x738adb) embed_message_support.add_field(name="Update:", value=announcement, inline=False) embed_message_support.add_field(name="How to update?", value='Nothing, updates roll out automatically! In order for the detailed new features to take place please give the bot a few minutes to process all servers, some features such as new slash commands may require up to an hour to finish implementing.', inline=False) embed_message_support.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) try: embed_message_support.set_author(name=announce_channel.guild.name, url=url_discord, icon_url=announce_channel.guild.icon.url) except AttributeError: embed_message_support.set_author(name=announce_channel.guild.name, url=url_discord, icon_url=img_unknown) pass embed_message_support.timestamp = datetime.datetime.now() embed_message_support.set_footer(text=txt_footer + str(embed_message_support.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: await announce_channel.send(embed=embed_message_support) except: pass embed_message_garrus = Embed(title='❕┃Developer Announcement Delivered', description='Please be aware Bot <@' + str(client.user.id) + '> has delivered the requested announcement to all Guild Owners:', color=0xffffff) embed_message_garrus.add_field(name="Announcement:", value=announcement, inline=False) embed_message_garrus.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_garrus.timestamp = datetime.datetime.now() embed_message_garrus.set_footer(text=txt_footer + str(embed_message_garrus.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) await ctx.channel.send(embed=embed_message_garrus) print(f'{client.user.name} has dispersed requested announcement to Guild Owners ' + ' @ ' + str(datetime.datetime.now())) elif len(cmd_list) < 2: await ctx.channel.send(content='❗┃**Announcement - Error**:\nPlease provide a statement to announce!', delete_after=180) elif (ctx.channel.id == 285530095005728778) & ('9015' in ctx.content) & (ctx.author.id != 284839059157942274): sql = "SELECT * FROM profiles WHERE discord_id = %s AND steam_id IS NOT NULL" val = (ctx.author.id,) await mysql_commit(sql=sql, val=val) current_profiles = sql_connect.fetchall() sql = "SELECT * FROM feature_log WHERE discord_id = %s" val = (ctx.author.id,) await mysql_commit(sql=sql, val=val) notified_hosts = sql_connect.fetchall() if (not current_profiles) & (not notified_hosts): developer = await client.fetch_user(224349699061186570) sql = "INSERT INTO feature_log (discord_id, inform_time) VALUES (%s, %s)" val = (ctx.author.id, datetime.datetime.now()) await mysql_commit(sql=sql, val=val) embed_message_help = Embed(title='New Stellaris LFG Service!', description='Hello there <@' + str(ctx.author.id) + '>, I noticed you posted a Stellaris Lobby ID just now in <#285530095005728778>, lets simplify and enhance the hosting process for you below!', color=0xffffff) embed_message_help.add_field(name="<:wsc_approved:504528451617685504>┃Help Improve WSC LFG:", value='• Please type below **[`/register`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/register)** and provide your **Steam Friend Code** now\n• Please then re-visit <#285530095005728778> and immediately type **[`/host`](https://valkyrinllc.gitbook.io/steamlfgservice/slash-commands/host)**\n• This will automatically create a Direct Join link into your Lobby, no more copy-pasting!', inline=False) # embed_message_help.add_field(name="<:wsc_approved:504528451617685504>┃WSC LFG has Changed:", value='• **Setup:** Visit <#285530095005728778> and run `/register` and provide me your Steam Friend Code.\n\n• **Usage:** Visit <#285530095005728778> and run `/host`, I will then ping `@Looking for Xenos` for you, provide your Lobby ID and, attach a `Join Game` button which will **automatically** launch Stellaris for any user without the need to copy the ID!!', inline=False) # embed_message_help.add_field(name="⭐┃Host Benefits:", value='• **Subscribers:** Whenever you run `/host` also attached will be a `🔔` button, when pressed it will sign a person up for automatic notifications for whenever you use `/host`! For example the notable host <@210549105477287938> has already gained over **23 subscriptions** to date! *Help yourself grow a following!*\n\n• **Karma:** Whenever you run `/host` also attached will be a `👍` button, when pressed you the host get **+1 Karma** (*a form of rating*). No longer must user\'s **@ thank you** in <#566230243103211521>. You can also see the server and global Karma leaderboards at anytime by running `/karma`, to fuel competition! <@210549105477287938> has already gained over **23 karma** to date!', inline=False) # embed_message_help.add_field(name="🕹️┃User Benefits:", value='• **Lobby Joining:** Whenever you run `/host` also attached will be a `🕹️ Join Game` button, if a user selects this, their game will automatically launch them into your Lobby. No more do they have to fumble entering in a Lobby ID manually, to help them save time!\n\n• **Automatic Role Pings:** As mentioned before, whenever you run `/host` I will automatically ping `@Looking for Xenos` **for you!!** Helps save you time and, maximize visibilty.\n\n• **Cross Server Posting:** Whenever you run `/host` your post will automatically appear on other particpating Stellaris LFG Discords like the `InterStellar Station (ISS)`. This greatly helps save you the time of posting to multiple servers! Users can also run `/search` to see your lobby at anytime in other Discords.', inline=False) # embed_message_help.add_field(name="❔┃Support for Hosts:", value='Thank you for your time reading this message. please dont hesitate to Direct Message <@224349699061186570> for questions.\n\n**Enjoy this new service built to help hosts like you!** <:ethos_militarist:444190651416838166> <:ethos_pacifist:444190856686075904>', inline=False) embed_message_help.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) embed_message_help.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) embed_message_help.timestamp = datetime.datetime.now() embed_message_help.set_footer(text=txt_footer + str(embed_message_help.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) try: await ctx.author.send(embed=embed_message_help, components=support_buttons) print('✔️┃ Notified Host - ID: ' + str(ctx.author.id) + ', Name: ' + str(ctx.author)) except: try: print('❗┃ Failed to Notify Host - ID: ' + str(ctx.author.id) + ', Name: ' + str(ctx.author) + ', Perhaps Closed DMs?') await developer.send(content='❗┃Failed to Notify Host - ID: ' + str(ctx.author.id) + ', Name: ' + str(ctx.author) + ', Perhaps Closed DMs?\n\n**Please reach out to them and explain manually!**') except: pass pass else: try: if (ctx.author.id == client.user.id) and (ctx.embeds[0].description == msg_process.description): await ctx.delete() except: pass # ############### Error Handling - Slash ######################## # @client.event # async def on_slash_command_error(inter, error): # # Submit Bug Report to developers # location = {} # exception_time = datetime.datetime.now() # # formatted_date = datetime.datetime.strptime(str(exception_time), "%Y-%m-%d %H:%M:%S.%f") # converted_date_utc = datetime.datetime.timestamp(formatted_date) # converted_date_utc = str(str(converted_date_utc).partition('.')[0]) # date_link = '[<t:' + converted_date_utc + ':F>](https://www.epochconverter.com/timezones?q=' + converted_date_utc + ')' # # try: # location = {str(inter.guild.id): str(inter.guild.name)} # except: # location = {'Private Message': str(inter.author.id)} # pass # user = {str(inter.author.id): str(inter.author)} # author_user = inter.author # print('\n❗┃Slash Command Error Encountered @ ' + str(exception_time) + ': \n• Type: `' + str(error) + '`\n• Location: `' + str(location) + '`\n• User: `' + str(user) + '`') # sql = "INSERT INTO exception_log (location, user, datetime, error_type, context, exception) VALUES (%s, %s, %s, %s, %s, %s)" # val = (str(location), str(user), exception_time, 'Slash Command', str(inter), str(error)) # await mysql_commit(sql=sql, val=val) # # # Inform user of error encountered, if permissions error also inform owner # msg_exception = Embed(title='❌┃Error Encountered', description='We apologize, an error was encountered whilst processing your **command**.', color=clr_error) # msg_exception.add_field(name='🛠️┃Error Name', value='`' + str(error) + '`', inline=False) # # try: # inter.guild.id # except: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='• **Note:** a **command** error report has been automatically submitted for developer review *within 48 hours*, if this issue persists or for further support use the below attached buttons.', inline=False) # pass # else: # if (str(error) == '403 Forbidden (error code: 50001): Missing Access') | (str(error) == '403 Forbidden (error code: 50013): Missing Permissions'): # msg_exception_owner = Embed(title='❌┃Server User Error Encountered', description='See below a request for your assistance in resolving an error.', color=clr_error) # msg_exception_owner.add_field(name='🛠️┃Error Name', value='`' + str(error) + '`', inline=False) # msg_exception_owner.add_field(name='❔┃What Occured', value='• At approximately ' + str(date_link) + ', user <@' + str(inter.author.id) + '>, encountered the above error whilst running <@' + str(client.user.id) + '>\'s commands in the channel <#' + str(inter.channel.id) + '>.\n• To resolve this issue, please update <@' + str(client.user.id) + '>\'s permissions in <#' + str(inter.channel.id) + '> to those listed on our **[Permissions Wiki](https://valkyrinllc.gitbook.io/steamlfgservice/permissions#inviting)**\n• Please also ensure <@' + str(client.user.id) + '> is not muted or timed out.', inline=False) # msg_exception_owner.timestamp = datetime.datetime.now() # msg_exception_owner.set_footer(text=txt_footer + str(msg_exception_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # msg_exception_owner.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) # try: # await inter.guild.owner.send(embed=msg_exception_owner) # except: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='\n• Please inform the Server Staff to give <@' + client.user.name + '> these listed **[Permissions](https://valkyrinllc.gitbook.io/steamlfgservice/permissions#inviting)**.\n• **Note:** A **command** error report has been automatically submitted for developer review *within 48 hours*, for further support use the below attached buttons.', inline=False) # pass # else: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='\n• We have automatically informed the Server Owner of your encountered error, so the required actions can be taken to resolve it.\n• **Note:** a **command** error report has been automatically submitted for developer review, for further support use the below attached buttons.', inline=False) # else: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='• **Note:** a **command** error report has been automatically submitted for developer review *within 48 hours*, if this issue persists or for further support use the below attached buttons.', inline=False) # # msg_exception.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) # msg_exception.timestamp = datetime.datetime.now() # msg_exception.set_footer(text=txt_footer + str(msg_exception.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # try: # msg_exception.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) # except AttributeError: # try: # msg_exception.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) # except AttributeError: # try: # msg_exception.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) # except AttributeError: # msg_exception.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) # pass # pass # pass # try: # await author_user.send(embed=msg_exception, components=support_buttons) # except: # pass # # # Inform developer of error encountered # developer = await client.fetch_user(224349699061186570) # msg_exception_developer = Embed(title='❗┃Slash Command Report', description='See below details of an automatic **command** error report.', color=clr_error) # msg_exception_developer.add_field(name='🛠️┃Error Name', value='`' + str(error)[:1000] + '`', inline=False) # msg_exception_developer.add_field(name='👥┃Content Object', value='`' + str(inter)[:1000] + '`', inline=False) # msg_exception_developer.add_field(name='❔┃Location & User', value='• **Location:** ' + str(location) + '\n• **User:** ' + str(user) + '\n• **Time:** ' + str(date_link), inline=False) # msg_exception_developer.timestamp = datetime.datetime.now() # msg_exception_developer.set_footer(text=txt_error + str(msg_exception_developer.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # msg_exception_developer.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) # await developer.send(embed=msg_exception_developer) # ############### Error Handling - Component ######################## # @client.event # async def on_component_callback_error(inter, ex, *args, **kwargs): # await inter.send(embed=msg_process, ephemeral=True, type=5) # # Submit Bug Report to developers # location = {} # exception_time = datetime.datetime.now() # # formatted_date = datetime.datetime.strptime(str(exception_time), "%Y-%m-%d %H:%M") # converted_date_utc = datetime.datetime.timestamp(formatted_date) # converted_date_utc = str(str(converted_date_utc).partition('.')[0]) # date_link = '[<t:' + converted_date_utc + ':F>](https://www.epochconverter.com/timezones?q=' + converted_date_utc + ')' # # try: # location = {str(inter.guild.id): str(inter.guild.name)} # except: # location = {'Private Message': str(inter.author.id)} # pass # user = {str(inter.author.id): str(inter.author)} # print('\n❗┃Component Callback Error Encountered @ ' + str(exception_time) + ': \n• Type: `' + str(ex) + '`\n• Location:' + str(location) + '`\n• User:' + str(user)) # sql = "INSERT INTO exception_log (location, user, datetime, error_type, context, exception) VALUES (%s, %s, %s, %s, %s, %s)" # val = (str(location), str(user), exception_time, 'Component Callback', str(inter), str(ex)) # await mysql_commit(sql=sql, val=val) # # # Inform user of error encountered # msg_exception = Embed(title='❌┃Error Encountered', description='We apologize, an error was encountered whilst processing your **interaction**.', color=clr_error) # msg_exception.add_field(name='🛠️┃Error Name', value='`' + str(ex) + '`', inline=False) # try: # inter.guild.id # except AttributeError: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='• **Note:** An **interaction** error report has been automatically submitted for developer review *within 48 hours*, if this issue persists or for further support use the below attached buttons.', inline=False) # pass # else: # msg_exception_owner = Embed(title='❌┃Server User Error Encountered', description='See below a request for your assistance in resolving an error.', color=clr_error) # msg_exception_owner.add_field(name='🛠️┃Error Name', value='`' + str(ex) + '`', inline=False) # msg_exception_owner.add_field(name='❔┃What Occured', value='At approximately ' + str(date_link) + ', user <@' + str(inter.author.id) + '>, encountered the above error whilst running <@' + str(client.user.id) + '>\'s commands in the channel <#' + str(inter.channel.id) + '>. To resolve this issue, please update <@' + str(client.user.id) + '>\'s permissions in <#' + str(inter.channel.id) + '> to those listed on our **[Permissions Wiki](https://valkyrinllc.gitbook.io/steamlfgservice/permissions#inviting)**.\n• **Note:** If these restrictions are on purpose, please disregard this message then and inform the user as such.', inline=False) # msg_exception_owner.timestamp = datetime.datetime.now() # msg_exception_owner.set_footer(text=txt_footer + str(msg_exception_owner.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # msg_exception_owner.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) # try: # await inter.guild.owner.send(embed=msg_exception_owner) # except: # if str(ex) == '403 Forbidden (error code: 50001): Missing Access': # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='\n• Please inform the Server Staff to give <@' + client.user.name + '> these listed **[Permissions](https://valkyrinllc.gitbook.io/steamlfgservice/permissions#inviting)**.\n• **Note:** An **interaction** error report has been automatically submitted for developer review *within 48 hours*, for further support use the below attached buttons.', inline=False) # else: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='• **Note:** An **interaction** error report has been automatically submitted for developer review *within 48 hours*, if this issue persists or for further support use the below attached buttons.', inline=False) # pass # else: # msg_exception.add_field(name='❔┃Troubleshooting Steps', value='\n• We have automatically informed the Server Owner of your encountered error, so the required actions can be taken to resolve it.\n• **Note:** An **interaction** error report has been automatically submitted for developer review, for further support use the below attached buttons.', inline=False) # msg_exception.add_field(name='💬┃Contact Us', value=txt_tip, inline=False) # msg_exception.timestamp = datetime.datetime.now() # msg_exception.set_footer(text=txt_footer + str(msg_exception.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # try: # msg_exception.set_author(name=inter.guild.name, url=url_discord, icon_url=inter.guild.icon.url) # except AttributeError: # try: # msg_exception.set_author(name=inter.guild.name, url=url_discord, icon_url=img_unknown) # except AttributeError: # try: # msg_exception.set_author(name=inter.author.name, url=url_discord, icon_url=inter.author.avatar.url) # except AttributeError: # msg_exception.set_author(name=inter.author.name, url=url_discord, icon_url=client.user.avatar.url) # pass # pass # pass # await inter.followup(embed=msg_exception, components=support_buttons, ephemeral=True) # # # Inform developer of error encountered # developer = await client.fetch_user(224349699061186570) # msg_exception_developer = Embed(title='❗┃Component Callback Report', description='See below details of an automatic **interaction** error report.', color=clr_error) # msg_exception_developer.add_field(name='🛠️┃Error Name', value='`' + str(ex) + '`', inline=False) # msg_exception_developer.add_field(name='👥┃Content Object', value='`' + str(inter) + '`', inline=False) # msg_exception_developer.add_field(name='❔┃Location & User', value='• Location: ' + str(location) + '\n• User: ' + str(user) + '\n• Time: ' + str(date_link), inline=False) # msg_exception_developer.timestamp = datetime.datetime.now() # msg_exception_developer.set_footer(text=txt_error + str(msg_exception_developer.timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[0:0]), icon_url=img_tip) # msg_exception_developer.set_author(name=client.user.name, url=url_discord, icon_url=client.user.avatar.url) # await developer.send(embed=msg_exception_developer) # ################ Client Run ######################## client.run(os.environ['AEGIS'])