Converting more shit to a slash commands

This commit is contained in:
Luke Robles 2022-10-18 13:56:22 -07:00
parent 93e5339f97
commit f638b38d3e
3 changed files with 67 additions and 44 deletions

View File

@ -33,12 +33,12 @@ async def on_ready():
) )
if os.getenv("DRAGON_ENV") == "prod": if os.getenv("DRAGON_ENV") == "prod":
for guild in bot.guilds: # for guild in bot.guilds:
await bot.register_commands(guild_id=guild.id, force=True) # await bot.register_commands(guild_id=guild.id, force=True)
await bot.get_channel(152921472304676865).send("I have reconnected") await bot.get_channel(152921472304676865).send("I have reconnected")
else: # else:
# force register commands in test server on launch # # force register commands in test server on launch
await bot.register_commands(guild_id=826547484632678450, force=True) # await bot.register_commands(guild_id=826547484632678450, force=True)
@bot.listen("on_message") @bot.listen("on_message")

View File

@ -1,3 +1,4 @@
from discord import option
from discord.ext import commands from discord.ext import commands
import core_utils import core_utils
import discord import discord
@ -16,13 +17,6 @@ class Cheeky(commands.Cog):
await ctx.reply(decide.decide(ctx.message.content)) await ctx.reply(decide.decide(ctx.message.content))
@commands.command(name="verify")
async def verify(self, ctx: commands.Context):
message = list(await ctx.message.channel.history(limit=2).flatten())[-1]
emoji = discord.utils.get(ctx.message.guild.emojis, name="verified")
if emoji:
await message.add_reaction(emoji)
@commands.command(name="coom", pass_context=True) @commands.command(name="coom", pass_context=True)
async def coom(self, ctx: commands.Context, id=None): async def coom(self, ctx: commands.Context, id=None):
if ctx.message.author.id != core_utils.my_id: if ctx.message.author.id != core_utils.my_id:
@ -35,28 +29,48 @@ class Cheeky(commands.Cog):
for emoji in await ctx.message.guild.fetch_emojis(): for emoji in await ctx.message.guild.fetch_emojis():
await message.add_reaction(emoji) await message.add_reaction(emoji)
@commands.command(name="clap") @commands.slash_command(
async def clap(self, ctx: commands.Context): guild_ids=None,
content = ctx.message.content.split()[1:] name="clap",
if len(content) == 1: description="Returns your passed in text separated by 👏",
content = [char for char in content[0]] )
await ctx.send("{}".format(" :clap: ".join(content))) @option(
name="input_string",
input_type="str",
description="The text you want to split",
required=True,
)
async def clap(self, ctx: commands.Context, input_string: str):
if len(input_string.split()) == 1:
input_string = [char for char in input_string]
await ctx.respond(" :clap: ".join(input_string))
else:
await ctx.respond(" :clap: ".join(input_string.split()) + " :clap: ")
@commands.command(name="greentext") @commands.slash_command(
guild_ids=None,
debug_guild=826547484632678450,
name="greentext",
description="Posts a greentext image",
)
async def greentext(self, ctx: commands.Context): async def greentext(self, ctx: commands.Context):
import get_from_reddit import get_from_reddit
await ctx.reply( embed = discord.Embed(
embed=core_utils.generate_embed( description=">implying this actually happened",
embed_title=">implying this actually happened", color=discord.Color.green(),
embed_color=discord.Color.green(), type="rich",
embed_url=get_from_reddit.get_image( )
boards=["aigreentext", "greentext", "newgreentexts", "4chan"]
), embed.set_image(
url=get_from_reddit.get_image(
boards=["aigreentext", "greentext", "newgreentexts", "4chan"]
) )
) )
await ctx.respond(embed=embed)
@commands.command(name="roll") @commands.command(name="roll")
async def roll( async def roll(
self, ctx: commands.Context, number_of_die, sides, number_to_add=None self, ctx: commands.Context, number_of_die, sides, number_to_add=None
@ -108,10 +122,10 @@ class Cheeky(commands.Cog):
) )
) )
@commands.command(name="donate", aliases=["subscribe"]) @commands.slash_command(name="donate")
async def donate(self, ctx: commands.Context): async def donate(self, ctx: commands.Context):
await ctx.reply( await ctx.respond(
"https://paypal.me/ldooks\nhttps://venmo.com/ldooks\nhttps://cash.me/$ldooks" "https://paypal.me/ldooks\nhttps://venmo.com/ldooks\nhttps://cash.me/$ldooks"
) )
@ -124,14 +138,17 @@ class Cheeky(commands.Cog):
await ctx.reply(result) await ctx.reply(result)
@commands.command(name="8ball") @commands.slash_command(
async def eight_ball(self, ctx: commands.Context): guild_ids=None, name="8ball", description="Ask the magic 8 ball a question"
)
@option(name="question", description="Your question", required=True)
async def eight_ball(self, ctx: commands.Context, question: str):
import eight_ball import eight_ball
result = eight_ball.check_8ball(ctx.message.content) result = eight_ball.check_8ball(question)
await ctx.reply(":8ball: %s :8ball:" % result) await ctx.respond(":8ball: %s :8ball:" % result)
@commands.command(name="flows") @commands.command(name="flows")
async def flows(self, ctx: commands.Context): async def flows(self, ctx: commands.Context):
@ -140,8 +157,17 @@ class Cheeky(commands.Cog):
result = river_stats.get_stats() result = river_stats.get_stats()
await ctx.reply(embed=result) await ctx.reply(embed=result)
@commands.command(name="twitter", aliases=["tweet"]) @commands.slash_command(
async def twitter(self, ctx: commands.Context, message_id): guild_ids=None,
name="tweet",
description="Returns an image of the pasted in message ID as a tweet",
)
@option(
name="message_id",
description="The message ID to turn into a tweet",
required=True,
)
async def twitter(self, ctx: commands.Context, message_id: str):
message = await ctx.channel.fetch_message(message_id) message = await ctx.channel.fetch_message(message_id)
author_avatar = message.author.avatar author_avatar = message.author.avatar
@ -156,13 +182,15 @@ class Cheeky(commands.Cog):
) )
with open("/tmp/tweet.jpg", "wb") as f: with open("/tmp/tweet.jpg", "wb") as f:
f.write(response.content) f.write(response.content)
await ctx.message.delete() # await ctx.message.delete()
await ctx.send(file=discord.File("/tmp/tweet.jpg")) await ctx.respond(file=discord.File("/tmp/tweet.jpg"))
@commands.command(name="sus") @commands.slash_command(
guild_ids=None, name="sus", description="Returns a sussy crewmate"
)
async def sus(self, ctx: commands.Context): async def sus(self, ctx: commands.Context):
if random.randint(0, 200) == 0: if random.randint(0, 200) == 0:
await ctx.reply( await ctx.respond(
""" """
``` ```
@ -179,7 +207,7 @@ class Cheeky(commands.Cog):
```""" ```"""
) )
else: else:
await ctx.reply( await ctx.respond(
""" """
``` ```

View File

@ -234,10 +234,6 @@ def get_help_message(method):
"\nGives the role permissions to enter the voice channel\n" "\nGives the role permissions to enter the voice channel\n"
"\nUsage: !vc some_role_name", "\nUsage: !vc some_role_name",
], ],
"verify": [
"Adds the twitter blue check mark to the previous message\n",
"\nLiterally thats all it does\n" "\nUsage: !verify",
],
} }
return "```css\n{}: {}\n```".format(method, " ".join(supported_methods[method])) return "```css\n{}: {}\n```".format(method, " ".join(supported_methods[method]))
@ -256,7 +252,6 @@ def get_help_embed(bot):
"nft", "nft",
"owo", "owo",
"sus", "sus",
"verify",
"wordle", "wordle",
], ],
"image utils": [ "image utils": [