|
1
|
|
|
import os |
|
2
|
|
|
import requests |
|
3
|
|
|
import asyncio |
|
4
|
|
|
import datetime |
|
5
|
|
|
import copy |
|
6
|
|
|
import random |
|
7
|
|
|
from collections import Counter |
|
8
|
|
|
from typing import Optional, Union |
|
9
|
|
|
import discord |
|
10
|
|
|
from discord.ext import commands |
|
11
|
|
|
from utils import colors, checks, converters, errors |
|
12
|
|
|
from utils.global_utils import confirm_prompt, send_embedded |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class fun(commands.Cog): |
|
16
|
|
|
"""weird, silly and fun commands that will probably make to smile""" |
|
17
|
|
|
|
|
18
|
|
|
def __init__(self, bot): |
|
19
|
|
|
self.bot = bot |
|
20
|
|
|
self._last_result = None |
|
21
|
|
|
|
|
22
|
|
|
@commands.command(name="yesno", aliases=["yn"]) |
|
23
|
|
|
async def yesorno(self, ctx): |
|
24
|
|
|
"""gives a gif with yes or no""" |
|
25
|
|
|
r = requests.get("https://yesno.wtf/api") |
|
26
|
|
|
j = r.json() |
|
27
|
|
|
|
|
28
|
|
|
embed = discord.Embed(title=j["answer"]) |
|
29
|
|
|
embed.set_image(url=j["image"]) |
|
30
|
|
|
embed.set_footer(text=f"Sent by {ctx.author}") |
|
31
|
|
|
await ctx.message.delete() |
|
32
|
|
|
await ctx.send(embed=embed) |
|
33
|
|
|
|
|
34
|
|
|
@commands.command(aliases=["tf", "face"]) |
|
35
|
|
|
async def textface(self, ctx, Type=None): |
|
36
|
|
|
"""gives out a funny textface""" |
|
37
|
|
|
if Type is None: |
|
38
|
|
|
await ctx.send( |
|
39
|
|
|
"That is NOT one of the dank textfaces in here yet. Use: *textface list to get a list of textfaces you can use." |
|
40
|
|
|
) |
|
41
|
|
|
else: |
|
42
|
|
|
if Type.lower() == "lenny": |
|
43
|
|
|
await ctx.send("( ͡° ͜ʖ ͡°)") |
|
44
|
|
|
elif Type.lower() == "tableflip": |
|
45
|
|
|
await ctx.send("(ノಠ益ಠ)ノ彡┻━┻") |
|
46
|
|
|
elif Type.lower() == "shrug": |
|
47
|
|
|
await ctx.send(r"¯\_(ツ)_/¯") |
|
48
|
|
|
elif Type.lower() == "bignose": |
|
49
|
|
|
await ctx.send("(͡ ͡° ͜ つ ͡͡°)") |
|
50
|
|
|
elif Type.lower() == "iwant": |
|
51
|
|
|
await ctx.send("ლ(´ڡ`ლ)") |
|
52
|
|
|
elif Type.lower() == "musicdude": |
|
53
|
|
|
await ctx.send("ヾ⌐*_*ノ♪") |
|
54
|
|
|
elif Type.lower() == "wot": |
|
55
|
|
|
await ctx.send("ლ,ᔑ•ﺪ͟͠•ᔐ.ლ") |
|
56
|
|
|
elif Type.lower() == "bomb": |
|
57
|
|
|
await ctx.send("(´・ω・)っ由") |
|
58
|
|
|
elif Type.lower() == "orlly": |
|
59
|
|
|
await ctx.send("﴾͡๏̯͡๏﴿ O'RLY?") |
|
60
|
|
|
elif Type.lower() == "money": |
|
61
|
|
|
await ctx.send("[̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]") |
|
62
|
|
|
elif Type.lower() == "list": |
|
63
|
|
|
em = discord.Embed(color=random.choice(self.bot.color_list), title="List of Textfaces") |
|
64
|
|
|
em.description = "Choose from the following: lenny, tableflip, shrug, bignose, iwant, musicdude, wot, bomb, orlly, money. Type *textface [face]." |
|
65
|
|
|
em.set_footer(text="Don't you dare question my names for the textfaces.") |
|
66
|
|
|
await ctx.send(embed=em) |
|
67
|
|
|
else: |
|
68
|
|
|
await send_embedded( |
|
69
|
|
|
ctx, |
|
70
|
|
|
"That is NOT one of the dank textfaces in here yet. Use !!textface list to see a list of the textfaces.", |
|
71
|
|
|
) |
|
72
|
|
|
await ctx.message.delete() |
|
73
|
|
|
|
|
74
|
|
|
@commands.group(case_insensitive=True, invoke_without_command=True) |
|
75
|
|
|
@commands.cooldown(3, 10, commands.BucketType.user) |
|
76
|
|
|
async def cat(self, ctx): |
|
77
|
|
|
"""cats! cats everywhere!""" |
|
78
|
|
|
await ctx.send_help(ctx.command) |
|
79
|
|
|
|
|
80
|
|
View Code Duplication |
async def get_cat(self, ctx, r): |
|
81
|
|
|
if r.status_code == 200: |
|
82
|
|
|
j = r.json() |
|
83
|
|
|
else: |
|
84
|
|
|
return await send_embedded(ctx, f"Error {r.status_code} in fetching the image. Try again later please.") |
|
85
|
|
|
|
|
86
|
|
|
embed = discord.Embed(title="A wild cat has appeared :cat:", color=random.choice(self.bot.color_list)) |
|
87
|
|
|
embed.set_image(url=j[0]["url"]) |
|
88
|
|
|
embed.set_footer(text=f"Image requested by {ctx.author}\nFetched from TheCatApi") |
|
89
|
|
|
await ctx.send(embed=embed) |
|
90
|
|
|
await ctx.message.delete(delay=60.0) |
|
91
|
|
|
|
|
92
|
|
|
@cat.command(name="gif") |
|
93
|
|
|
async def gif(self, ctx): |
|
94
|
|
|
"""yes a cat gif""" |
|
95
|
|
|
header = {"x-api-key": self.bot.config["keys"]["cat_api"]} |
|
96
|
|
|
r = requests.get(url="https://api.thecatapi.com/v1/images/search?mime_types=gif", headers=header) |
|
97
|
|
|
await self.get_cat(ctx, r) |
|
98
|
|
|
|
|
99
|
|
|
@cat.command(name="pic") |
|
100
|
|
|
async def pic(self, ctx): |
|
101
|
|
|
"""yes a cat pic""" |
|
102
|
|
|
header = {"x-api-key": self.bot.config["keys"]["cat_api"]} |
|
103
|
|
|
r = requests.get(url="https://api.thecatapi.com/v1/images/search?mime_types=jpg,png", headers=header) |
|
104
|
|
|
print(r) |
|
105
|
|
|
await self.get_cat(ctx, r) |
|
106
|
|
|
|
|
107
|
|
|
@commands.group(case_insensitive=True, invoke_without_command=True) |
|
108
|
|
|
@commands.cooldown(3, 10, commands.BucketType.user) |
|
109
|
|
|
async def dog(self, ctx): |
|
110
|
|
|
"""doggo doggo doggo""" |
|
111
|
|
|
await ctx.send_help(ctx.command) |
|
112
|
|
|
|
|
113
|
|
|
# IDEA: Allow people to list breeds and search by breeds |
|
114
|
|
View Code Duplication |
async def get_dog(self, ctx, r): |
|
115
|
|
|
if r.status_code == 200: |
|
116
|
|
|
j = r.json() |
|
117
|
|
|
else: |
|
118
|
|
|
return await send_embedded(ctx, f"Error {r.status_code} in fetching the image. Try again later please.") |
|
119
|
|
|
|
|
120
|
|
|
embed = discord.Embed(title="OMG a doggo :dog:", color=random.choice(self.bot.color_list)) |
|
121
|
|
|
embed.set_image(url=j[0]["url"]) |
|
122
|
|
|
embed.set_footer(text=f"Image requested by {ctx.author}\nFetched from TheDogApi") |
|
123
|
|
|
await ctx.send(embed=embed) |
|
124
|
|
|
await ctx.message.delete(delay=60.0) |
|
125
|
|
|
|
|
126
|
|
|
@dog.command(name="gif") |
|
127
|
|
|
async def _gif(self, ctx): |
|
128
|
|
|
"""A dog gif""" |
|
129
|
|
|
header = {"x-api-key": self.bot.config["keys"]["dog_api"]} |
|
130
|
|
|
r = requests.get(url="https://api.thedogapi.com/v1/images/search?mime_types=gif", headers=header) |
|
131
|
|
|
await self.get_dog(ctx, r) |
|
132
|
|
|
|
|
133
|
|
|
@dog.command(name="pic") |
|
134
|
|
|
async def _pic(self, ctx): |
|
135
|
|
|
"""a dog pic""" |
|
136
|
|
|
header = {"x-api-key": self.bot.config["keys"]["dog_api"]} |
|
137
|
|
|
r = requests.get(url="https://api.thedogapi.com/v1/images/search?mime_types=jpg,png", headers=header) |
|
138
|
|
|
await self.get_dog(ctx, r) |
|
139
|
|
|
|
|
140
|
|
|
# REVIEW: check if command is working or not |
|
141
|
|
|
# NOTE: extend the limit to get more gifs if ever needed |
|
142
|
|
|
@commands.command(name="giphy", aliases=["giffy", "jiff"]) |
|
143
|
|
|
@commands.cooldown(3, 10, commands.BucketType.user) |
|
144
|
|
|
async def giphy(self, ctx, *, search=None): |
|
145
|
|
|
"""gets a random gif from giphy""" |
|
146
|
|
|
head = {"api_key": self.bot.config["keys"]["giphy_api"]} |
|
147
|
|
|
|
|
148
|
|
|
if search is None: |
|
149
|
|
|
r = requests.get(url="http://api.giphy.com/v1/gifs/trending", headers=head) |
|
150
|
|
|
else: |
|
151
|
|
|
search.replace(" ", "+") |
|
152
|
|
|
url = f"http://api.giphy.com/v1/gifs/search?q={search}" |
|
153
|
|
|
r = requests.get(url=url, headers=head) |
|
154
|
|
|
|
|
155
|
|
|
if r.status_code == 200: |
|
156
|
|
|
j = r.json() |
|
157
|
|
|
else: |
|
158
|
|
|
return await send_embedded(ctx, f"Error {r.status_code} in fetching the image. Try again later please.") |
|
159
|
|
|
|
|
160
|
|
|
rand = random.choice(j["data"]) |
|
161
|
|
|
gif_title = rand["title"] |
|
162
|
|
|
gif_url = rand["images"]["downsized_large"]["url"] |
|
163
|
|
|
|
|
164
|
|
|
embed = discord.Embed( |
|
165
|
|
|
title=gif_title, color=random.choice(self.bot.color_list), description=f"requested by {ctx.author}" |
|
166
|
|
|
) |
|
167
|
|
|
embed.set_image(url=gif_url) |
|
168
|
|
|
embed.set_footer(text="Powered by GIPHY") |
|
169
|
|
|
await ctx.send(embed=embed) |
|
170
|
|
|
|
|
171
|
|
|
# https://nekos.life/api/v2/img/slap |
|
172
|
|
|
# api for various stuff including nsfw content |
|
173
|
|
|
|
|
174
|
|
|
# NOTE: othher gif APIs include gfycat and tenor |
|
175
|
|
|
|
|
176
|
|
|
@commands.command(name="memes", aliases=["meme", "meem"], help="get a meme from r/me_irl, r/dankmemes and r/memes") |
|
177
|
|
|
@commands.cooldown(3, 10, commands.BucketType.user) |
|
178
|
|
|
async def memes(self, ctx): |
|
179
|
|
|
"""get a meme from r/me_irl, r/dankmemes and r/memes""" |
|
180
|
|
|
r = requests.get(url="https://meme-api.herokuapp.com/gimme") |
|
181
|
|
|
|
|
182
|
|
|
if r.status_code == 200: |
|
183
|
|
|
j = r.json() |
|
184
|
|
|
else: |
|
185
|
|
|
return await send_embedded(ctx, f"Error {r.status_code} in fetching the image. Try again later please.") |
|
186
|
|
|
|
|
187
|
|
|
sub = j["subreddit"] |
|
188
|
|
|
embed = discord.Embed( |
|
189
|
|
|
title=j["title"], description=f"posted on r/{sub}", color=random.choice(self.bot.color_list) |
|
190
|
|
|
) |
|
191
|
|
|
embed.set_image(url=j["url"]) |
|
192
|
|
|
embed.set_footer(text=f"Requested by {ctx.author} 👾") |
|
193
|
|
|
await ctx.send(embed=embed) |
|
194
|
|
|
|
|
195
|
|
|
# TODO: Reddit command to fetch memes and gifs from reddit |
|
196
|
|
|
|
|
197
|
|
|
|
|
198
|
|
|
def setup(bot): |
|
199
|
|
|
bot.add_cog(fun(bot)) |
|
200
|
|
|
|