Converting more shit to a slash command
This commit is contained in:
parent
104d79501a
commit
fb522c015e
@ -1,4 +1,5 @@
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from discord.commands import Option
|
||||||
import discord
|
import discord
|
||||||
import os
|
import os
|
||||||
import get_from_reddit
|
import get_from_reddit
|
||||||
@ -10,8 +11,19 @@ class ActualUtils(commands.Cog):
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot: commands.Bot = bot
|
self.bot: commands.Bot = bot
|
||||||
|
|
||||||
@commands.command(name="youtube", aliases=["yt"])
|
@commands.slash_command(
|
||||||
async def youtube(self, ctx: commands.Context, *, query):
|
guild_ids=None,
|
||||||
|
name="youtube",
|
||||||
|
aliases=["yt"],
|
||||||
|
description="Search youtube for the passed in query",
|
||||||
|
)
|
||||||
|
async def youtube(
|
||||||
|
self,
|
||||||
|
ctx,
|
||||||
|
query: Option(
|
||||||
|
str, "What video you want to search for on youtube", required=True
|
||||||
|
),
|
||||||
|
):
|
||||||
import re
|
import re
|
||||||
from urllib import parse, request
|
from urllib import parse, request
|
||||||
|
|
||||||
@ -21,7 +33,8 @@ class ActualUtils(commands.Cog):
|
|||||||
|
|
||||||
result = "https://www.youtube.com/watch?v=" + search_results[0]
|
result = "https://www.youtube.com/watch?v=" + search_results[0]
|
||||||
|
|
||||||
await ctx.reply(result)
|
await ctx.defer()
|
||||||
|
await ctx.followup.send(result)
|
||||||
|
|
||||||
@commands.command(name="issue")
|
@commands.command(name="issue")
|
||||||
async def issue(self, ctx: commands.Context):
|
async def issue(self, ctx: commands.Context):
|
||||||
@ -67,19 +80,32 @@ class ActualUtils(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@commands.has_role("stable-diffuser")
|
@commands.has_role("stable-diffuser")
|
||||||
@commands.command(name="sd")
|
@commands.slash_command(
|
||||||
async def sd(self, ctx: commands.Context, *, prompt):
|
guild_ids=None,
|
||||||
|
name="sd",
|
||||||
|
description="Pass a prompt and optinal negative prompt to stable diffusion",
|
||||||
|
)
|
||||||
|
async def sd(
|
||||||
|
self,
|
||||||
|
ctx: commands.Context,
|
||||||
|
positive_prompt: Option(
|
||||||
|
str, "The positive prompt to send to stable-diffusion", required=True
|
||||||
|
),
|
||||||
|
negative_prompt: Option(
|
||||||
|
str,
|
||||||
|
"An optinal negative prompt to send to stable-diffusion",
|
||||||
|
required=False,
|
||||||
|
),
|
||||||
|
):
|
||||||
import socket
|
import socket
|
||||||
import stable_diffusion
|
import stable_diffusion
|
||||||
|
|
||||||
port = "7860"
|
port = "7860"
|
||||||
ip = "192.168.1.80"
|
ip = "192.168.1.80"
|
||||||
steps = 20
|
steps = 20
|
||||||
negatives = ""
|
|
||||||
positives = prompt
|
|
||||||
|
|
||||||
# Send my requests to my gaming computer with the 3080 (if its up)
|
# Send my requests to my gaming computer with the 3080 (if its up)
|
||||||
if ctx.message.author.id == 144986109804412928:
|
if ctx.author.id == 144986109804412928:
|
||||||
ip = "192.168.1.188"
|
ip = "192.168.1.188"
|
||||||
steps = 60
|
steps = 60
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
@ -90,14 +116,16 @@ class ActualUtils(commands.Cog):
|
|||||||
ip = "192.168.1.80"
|
ip = "192.168.1.80"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
original_message = await ctx.reply(
|
await ctx.defer()
|
||||||
|
original_message = await ctx.followup.send(
|
||||||
"Please be patient, I'm generating your image"
|
"Please be patient, I'm generating your image"
|
||||||
)
|
)
|
||||||
if ";" in prompt:
|
|
||||||
positives = prompt.split(";")[0]
|
|
||||||
negatives = prompt.split(";")[1]
|
|
||||||
file_path = await stable_diffusion.generate_image(
|
file_path = await stable_diffusion.generate_image(
|
||||||
ip=ip, port=port, positives=positives, negatives=negatives, steps=steps
|
ip=ip,
|
||||||
|
port=port,
|
||||||
|
positives=positive_prompt,
|
||||||
|
negatives=negative_prompt or None,
|
||||||
|
steps=steps,
|
||||||
)
|
)
|
||||||
await original_message.edit(
|
await original_message.edit(
|
||||||
content="",
|
content="",
|
||||||
@ -113,11 +141,16 @@ class ActualUtils(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@commands.has_role("Track day gamers")
|
@commands.has_role("Track day gamers")
|
||||||
@commands.command(name="trackdays")
|
@commands.slash_command(
|
||||||
|
guild_ids=None,
|
||||||
|
name="trackdays",
|
||||||
|
description="Query motorsportsreg.com for a list of trackdays going on at Buttonwillow and Thunderhill",
|
||||||
|
)
|
||||||
async def trackdays(self, ctx: commands.Context):
|
async def trackdays(self, ctx: commands.Context):
|
||||||
import trackdays
|
import trackdays
|
||||||
|
|
||||||
for track, events in trackdays.get_msreg().items():
|
shid = await trackdays.get_msreg()
|
||||||
|
for track, events in shid.items():
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description=":checkered_flag: **Upcoming events at %s**:checkered_flag: "
|
description=":checkered_flag: **Upcoming events at %s**:checkered_flag: "
|
||||||
% track,
|
% track,
|
||||||
@ -136,8 +169,7 @@ class ActualUtils(commands.Cog):
|
|||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Event URL", value=track_day["event_url"], inline=False
|
name="Event URL", value=track_day["event_url"], inline=False
|
||||||
)
|
)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
await ctx.reply(embed=embed)
|
|
||||||
|
|
||||||
@commands.command(name="corona", aliases=["covid"])
|
@commands.command(name="corona", aliases=["covid"])
|
||||||
async def corona(self, ctx: commands.Context, *, location=None):
|
async def corona(self, ctx: commands.Context, *, location=None):
|
||||||
|
@ -35,7 +35,10 @@ class QuickPoll(commands.Cog):
|
|||||||
for x, option in enumerate(options):
|
for x, option in enumerate(options):
|
||||||
description += "\n {} {}".format(reactions[x], option)
|
description += "\n {} {}".format(reactions[x], option)
|
||||||
embed = discord.Embed(title=question, description="".join(description))
|
embed = discord.Embed(title=question, description="".join(description))
|
||||||
react_message = await ctx.send(embed=embed)
|
|
||||||
|
await ctx.defer()
|
||||||
|
react_message = await ctx.followup.send(embed=embed)
|
||||||
|
|
||||||
for reaction in reactions[: len(options)]:
|
for reaction in reactions[: len(options)]:
|
||||||
await react_message.add_reaction(reaction)
|
await react_message.add_reaction(reaction)
|
||||||
embed.set_footer(text="Poll ID: {}".format(react_message.id))
|
embed.set_footer(text="Poll ID: {}".format(react_message.id))
|
||||||
|
@ -79,7 +79,7 @@ def get_help_message(method):
|
|||||||
"emoji": [
|
"emoji": [
|
||||||
"Uploads the passed in URL to the server as an emoji.",
|
"Uploads the passed in URL to the server as an emoji.",
|
||||||
"\nDiscord does not support GIFS. It will throw an error if you try."
|
"\nDiscord does not support GIFS. It will throw an error if you try."
|
||||||
"\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji\n"
|
"\nUsage: !emoji http://pictures.com/some_image.png my_new_emoji\n",
|
||||||
],
|
],
|
||||||
"excuse": [
|
"excuse": [
|
||||||
"Generates a random excuse you can give your boss",
|
"Generates a random excuse you can give your boss",
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import requests
|
import httpx
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
|
||||||
def get_msreg():
|
async def get_msreg():
|
||||||
base_url = "https://api.motorsportreg.com/rest/calendars/organization"
|
base_url = "https://api.motorsportreg.com/rest/calendars/organization"
|
||||||
orgs = {
|
orgs = {
|
||||||
"speeddistrict": "2E22740B-E8C9-9FB9-21406A496429A28B",
|
"speeddistrict": "2E22740B-E8C9-9FB9-21406A496429A28B",
|
||||||
@ -18,13 +18,15 @@ def get_msreg():
|
|||||||
"socaldriversclub": "B4FC0113-C903-E9D3-68562D6765806945",
|
"socaldriversclub": "B4FC0113-C903-E9D3-68562D6765806945",
|
||||||
}
|
}
|
||||||
events = {}
|
events = {}
|
||||||
|
client = httpx.AsyncClient()
|
||||||
for org_name, org_id in orgs.items():
|
for org_name, org_id in orgs.items():
|
||||||
xml_blob = requests.get(
|
xml_blob = await client.get(
|
||||||
"%s/%s?exclude_cancelled=true&postalcode=94549&radius=500"
|
"%s/%s?exclude_cancelled=true&postalcode=94549&radius=500"
|
||||||
% (base_url, org_id)
|
% (base_url, org_id)
|
||||||
).text
|
)
|
||||||
|
awaited_xml_blob = xml_blob.text
|
||||||
json_blob = json.loads(
|
json_blob = json.loads(
|
||||||
json.dumps(xmltodict.parse(xml_blob)["response"]["events"])
|
json.dumps(xmltodict.parse(awaited_xml_blob)["response"]["events"])
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user