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'):
await client.send_message(
message.channel,
embed=generate_embed(
embed_url=lewds.get_lewd(channel_name=message.channel.name),
embed_title="{} is being lewd".format(message.author.name)
if 'nsfw' in message.channel.name:
await client.send_message(
message.channel,
embed=generate_embed(
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'):
await client.send_message(

View File

@ -41,25 +41,31 @@ def get_from_danbooru(boards, nsfw=True):
return get_from_danbooru(boards)
def get_lewd(channel_name):
if 'nsfw' in channel_name:
boards = [
'2Booty',
'ahegao',
'bakunyuu_hentai',
'ecchi',
'hentai',
'rule34',
'WesternHentai',
'doujinshi',
'hentai_gif',
'muchihentai',
'chiisaihentai',
'dekaihentai',
'WaifusGonewild',
'thighdeology'
]
def get_lewd():
"""
get_lewd()
# 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)
return 'You can only use this command in NSFW channels'
Chooses between getting from reddit or danbooru
If reddit is chosen, picks a random subreddit from the list of boards and
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)