Fixing the lewd error message if someone tries to use it in a not lewd channel

This commit is contained in:
luke 2018-03-19 13:54:54 -07:00
parent dd6e1d303e
commit 35e2cd0b10
2 changed files with 39 additions and 27 deletions

View File

@ -226,13 +226,19 @@ async def on_message(message):
) )
if message.content.startswith('!lewd'): if message.content.startswith('!lewd'):
await client.send_message( if 'nsfw' in message.channel.name:
message.channel, await client.send_message(
embed=generate_embed( message.channel,
embed_url=lewds.get_lewd(channel_name=message.channel.name), embed=generate_embed(
embed_title="{} is being lewd".format(message.author.name) embed_url=lewds.get_lewd(channel_name=message.channel.name),
embed_title="{} is being lewd".format(message.author.name)
)
)
else:
await client.send_message(
message.channel,
'You can only use this command in NSFW channels'
) )
)
if message.content.startswith('!weather'): if message.content.startswith('!weather'):
await client.send_message( await client.send_message(

View File

@ -41,25 +41,31 @@ def get_from_danbooru(boards, nsfw=True):
return get_from_danbooru(boards) return get_from_danbooru(boards)
def get_lewd(channel_name): def get_lewd():
if 'nsfw' in channel_name: """
boards = [ get_lewd()
'2Booty',
'ahegao',
'bakunyuu_hentai',
'ecchi',
'hentai',
'rule34',
'WesternHentai',
'doujinshi',
'hentai_gif',
'muchihentai',
'chiisaihentai',
'dekaihentai',
'WaifusGonewild',
'thighdeology'
]
# This is really bad practice but pass boards to get_from_reddit AND danbooru so it doesnt error Chooses between getting from reddit or danbooru
return random.choice([get_from_reddit.get_image, get_from_danbooru])(boards=boards, nsfw=True) If reddit is chosen, picks a random subreddit from the list of boards and
return 'You can only use this command in NSFW channels' grabs a random image using the get_from_reddit() method
"""
# List of subreddits that have the lewds we seek
boards = [
'2Booty',
'ahegao',
'bakunyuu_hentai',
'ecchi',
'hentai',
'rule34',
'WesternHentai',
'doujinshi',
'hentai_gif',
'muchihentai',
'chiisaihentai',
'dekaihentai',
'WaifusGonewild',
'thighdeology'
]
# This is really bad practice but pass boards to get_from_reddit AND danbooru so it doesnt error
return random.choice([get_from_reddit.get_image, get_from_danbooru])(boards=boards, nsfw=True)