utilisation nouvelle méthode pour les slashcommands et changement complet de la commande NSFW
This commit is contained in:
parent
e5d3319841
commit
a46cb38b2d
1 changed files with 38 additions and 58 deletions
|
@ -5,7 +5,7 @@ from discord.ext import commands
|
|||
from random import choice
|
||||
from asyncpraw import Reddit
|
||||
from discord_slash import cog_ext
|
||||
from utils.core import randomImage
|
||||
from utils.core import randomImage, isSlash
|
||||
|
||||
def setup(client):
|
||||
client.add_cog(Internet(client))
|
||||
|
@ -18,15 +18,7 @@ class Internet(commands.Cog):
|
|||
@commands.command(name='memes', aliases = ['meme'])
|
||||
async def _memes(self, ctx, *args):
|
||||
"""Envoie un meme de reddit.\n ➡ Syntaxe: {PREFIX}memes/meme [subreddit]"""
|
||||
fromSlash = False
|
||||
if len(args) > 0:
|
||||
if args[-1] == True:
|
||||
fromSlash = args[-1]
|
||||
args = args[:-1]
|
||||
if len(args) > 0:
|
||||
args = args[0]
|
||||
else:
|
||||
args = None
|
||||
args, fromSlash, _ = isSlash(args)
|
||||
|
||||
if args: # s'il y a un subreddit de défini
|
||||
subredditchoix = args
|
||||
|
@ -35,6 +27,9 @@ class Internet(commands.Cog):
|
|||
'educationalmemes', 'funny', 'marvelmemes', 'me_irl', 'meme', 'MemeEconomy', 'Memes_Of_The_Dank', 'MinecraftMemes',
|
||||
'physicsmemes', 'blackpeopletwitter', 'metal_me_irl', '195', 'shittyadviceanimals', 'meirl',
|
||||
'2meirl4meirl', 'AdviceAnimals', 'weirdmemes', 'LeagueOfMemes'])
|
||||
|
||||
if fromSlash != None and subredditchoix == "nsfw": # demande de nsfw sans passé par la commande appropriée
|
||||
return await ctx.send(f"Désolé, tu demandes du nsfw... Fais plutôt **{ctx.prefix}sexe**.")
|
||||
|
||||
try:
|
||||
async with Reddit(client_id = environ['TOKEN_REDDIT_CLIENT_ID'], client_secret = environ['TOKEN_REDDIT_CLIENT_SECRET'], user_agent = f"disreddit /u/{environ['TOKEN_REDDIT_USER_AGENT']}, http://localhost:8080") as reddit:
|
||||
|
@ -43,18 +38,28 @@ class Internet(commands.Cog):
|
|||
all_subs = [item async for item in hot] # liste des memes
|
||||
submission = choice(all_subs) # choix aléatoire
|
||||
|
||||
image = ["png", "jpg", "jpeg", "bmp", "gif"]
|
||||
image = ["png", "jpg", "jpeg", "bmp", "gif"] # gifv not working
|
||||
if submission.url[-3:] in image:
|
||||
embed = discord.Embed(title = f"r/{subredditchoix} pour {ctx.author.name}", color = discord.Colour.random(), description = f"[lien du meme]({submission.url})")
|
||||
embed.set_footer(text = f"Meme de Reddit")
|
||||
if fromSlash != None:
|
||||
footer = "Meme de Reddit"
|
||||
memeOuImage = "[lien du meme]"
|
||||
else:
|
||||
footer = "NSFW de Reddit"
|
||||
memeOuImage = "[lien de l'image]"
|
||||
embed = discord.Embed(title = f"r/{subredditchoix} pour {ctx.author.name}", color = discord.Colour.random(), description = f"{memeOuImage}({submission.url})")
|
||||
embed.set_footer(text = footer)
|
||||
embed.set_image(url = submission.url)
|
||||
message = await ctx.send(embed = embed)
|
||||
else:
|
||||
message = await ctx.send(f"```r/{subredditchoix} pour {ctx.author.name}```\n{submission.url}")
|
||||
if fromSlash != True:
|
||||
if fromSlash != None:
|
||||
message = await ctx.send(f"`r/{subredditchoix} pour {ctx.author.name}`\n{submission.url}")
|
||||
else:
|
||||
message = await ctx.send(f"`{subredditchoix.capitalize()} pour {ctx.author.name}`\n{submission.url}")
|
||||
if fromSlash != True and fromSlash != None:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
await message.add_reaction('🔺')
|
||||
return await message.add_reaction('🔻')
|
||||
if fromSlash != None:
|
||||
for emoji in ['🔺', '🔻']:
|
||||
await message.add_reaction(emoji)
|
||||
|
||||
except Exception as error:
|
||||
print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}")
|
||||
|
@ -63,14 +68,17 @@ class Internet(commands.Cog):
|
|||
return await ctx.send(f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})")
|
||||
@cog_ext.cog_slash(name="meme", description = "Envoie un meme de reddit.")
|
||||
async def __memes(self, ctx, subreddit = None):
|
||||
ctx.prefix = "/"
|
||||
if subreddit == None:
|
||||
return await self._memes(ctx, True)
|
||||
else:
|
||||
return await self._memes(ctx, subreddit, True)
|
||||
|
||||
@commands.command(name='cat', aliases = ['chat'])
|
||||
async def _cat(self, ctx, fromSlash = False):
|
||||
async def _cat(self, ctx, fromSlash = None):
|
||||
"""Te montre un magnifique chat.\n ➡ Syntaxe: {PREFIX}cat/chat"""
|
||||
if fromSlash != True:
|
||||
fromSlash = False
|
||||
|
||||
if ctx.author.nick:
|
||||
name = f"{ctx.author.nick} ({ctx.author.name}#{ctx.author.discriminator})"
|
||||
|
@ -91,7 +99,7 @@ class Internet(commands.Cog):
|
|||
@commands.command(name='dog', aliases = ['chien'])
|
||||
async def _dog(self, ctx, fromSlash = None):
|
||||
"""Te montre un magnifique chien.\n ➡ Syntaxe: {PREFIX}dog/chien"""
|
||||
if fromSlash == None:
|
||||
if fromSlash != True:
|
||||
fromSlash = False
|
||||
|
||||
if ctx.author.nick:
|
||||
|
@ -111,57 +119,29 @@ class Internet(commands.Cog):
|
|||
return await self._dog(ctx, True)
|
||||
|
||||
@commands.command(name='sexe', aliases=['sexes', 'nude', 'nudes', 'nsfw'])
|
||||
async def _sexe(self, ctx, *choice_of_nsfw):
|
||||
"""Envois une image coquine. (NSFW)\n ➡ Syntaxe: {PREFIX}sexe/sexes/nude/nudes [butts/boobs]"""
|
||||
fromSlash = False
|
||||
if len(choice_of_nsfw) > 0:
|
||||
if choice_of_nsfw[-1] == True:
|
||||
fromSlash = choice_of_nsfw[-1]
|
||||
choice_of_nsfw = choice_of_nsfw[:-1]
|
||||
if len(choice_of_nsfw) > 0:
|
||||
choice_of_nsfw = choice_of_nsfw[0]
|
||||
else:
|
||||
choice_of_nsfw = None
|
||||
|
||||
liste_hot = ['butts', 'boobs']
|
||||
if choice_of_nsfw == 'butt':
|
||||
choice_of_nsfw = 'butts'
|
||||
if choice_of_nsfw == 'boob':
|
||||
choice_of_nsfw = 'boobs'
|
||||
if choice_of_nsfw in liste_hot:
|
||||
pass
|
||||
else:
|
||||
choice_of_nsfw = choice(liste_hot)
|
||||
async def _sexe(self, ctx, fromSlash = None):
|
||||
"""Envois une image coquine. (NSFW)\n ➡ Syntaxe: {PREFIX}sexe/sexes/nude/nudes"""
|
||||
if fromSlash != True:
|
||||
fromSlash = False
|
||||
if ctx.channel.is_nsfw():
|
||||
embed = discord.Embed(title = f"{choice_of_nsfw.capitalize()} pour {ctx.author.name}", colour = discord.Colour.random())
|
||||
nsfw = randomImage(f'http://api.o{choice_of_nsfw}.ru/noise/')
|
||||
embed.set_image(url = f"http://media.o{choice_of_nsfw}.ru/{nsfw[0][0]['preview']}")
|
||||
embed.set_footer(text = f"o{choice_of_nsfw}.ru a pris {nsfw[1]} ms pour sortir l'image n°{nsfw[0][1]}-{nsfw[1]}.")
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
await ctx.send(embed = embed)
|
||||
else:
|
||||
ctx.prefix = "/"
|
||||
return await self._memes(ctx, "nsfw", None)
|
||||
else:
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '❌')
|
||||
await ctx.send(f"Désolé mais je n'envois ce genre de message seulement dans les salons NSFW !")
|
||||
@cog_ext.cog_slash(name="sexe", description = "Envois une image coquine. (NSFW)")
|
||||
async def __sexe(self, ctx, buttsorboobs = None):
|
||||
if buttsorboobs == None:
|
||||
return await self._sexe(ctx, True)
|
||||
else:
|
||||
return await self._sexe(ctx, buttsorboobs, True)
|
||||
async def __sexe(self, ctx):
|
||||
return await self._sexe(ctx, True)
|
||||
|
||||
@commands.command(name='news', aliases=['rss'])
|
||||
async def _news(self, ctx, *arg):
|
||||
"""Info random dans le domaine de l'informatique\n ➡ Syntaxe: {PREFIX}news/rss [site/liste]"""
|
||||
fromSlash = False
|
||||
if len(arg) > 0:
|
||||
if arg[-1] == True:
|
||||
fromSlash = arg[-1]
|
||||
arg = arg[:-1]
|
||||
if len(arg) > 0:
|
||||
arg = arg[0]
|
||||
else:
|
||||
arg, fromSlash, _ = isSlash(arg)
|
||||
if arg == None:
|
||||
arg = ""
|
||||
|
||||
rss_website = {
|
||||
|
|
Reference in a new issue