-
Notifications
You must be signed in to change notification settings - Fork 0
/
trivia.py
149 lines (117 loc) · 4.8 KB
/
trivia.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
######### TRIVIA #########
import discord
from discord.ext import commands
import random
import time
import json
waifus=json.loads(open("waifus.json").read())
waifus=sorted(waifus, key=lambda w: w["likes"]+w["trash"])
channel_used_whoisthiswaifu = {}
channel_used_waifufromwhatanimu = {}
class trivia:
def __init__(self, client):
self.client = client
##### WHO IS THIS WAIFU? #####
@commands.command(pass_context=True)
async def whoisthiswaifu(self, ctx, dif : str = "m"):
if dif == "e":
waifus2cuck=waifus[-100:]
elif dif == "m":
waifus2cuck=waifus[-1000:]
elif dif == "h":
waifus2cuck=waifus[-8000:]
elif dif == "suicide":
waifus2cuck=waifus
channel = ctx.message.channel
author = ctx.message.author
print(dif)
if not channel.id in channel_used_whoisthiswaifu:
channel_used_whoisthiswaifu[channel.id] = True
else:
if channel_used_whoisthiswaifu[channel.id] == True:
await self.client.say("You are already playing Who Is This Waifu, don't rush it.")
return
else:
channel_used_whoisthiswaifu[channel.id] = True
while True:
waifu=waifus2cuck[random.randint(0, len(waifus2cuck)-1)]
waifuName = waifu['name']
waifuImg = waifu['display_picture']
await self.client.say("**Who Is This Waifu?**")
await self.client.say("*Type the complete name of the waifu. Everyone in the channel can participate. Yay!*")
await self.client.send_file(channel, waifuImg)
await self.client.say("Type `next` for another waifu (accessible by %s). \nType `stop` to end the cmd (accessible by %s)" % (author, author))
start = time.time()
while time.time()<(start+60):
print("inside while")
m = await self.client.wait_for_message(channel=channel, timeout=1)
print("pepe")
if time.time()>=(start+60):
await self.client.say("Oops! Nobody got it right. The name of the waifu is %s." % (waifuName))
channel_used_whoisthiswaifu[channel.id] = False
return
if m is None:
continue
if (m.content).lower() ==(waifuName).lower():
await self.client.say("Nice job! %s guessed the name right! The answer was %s" % (m.author, waifuName))
break
if m.content == "next" and m.author == author:
break
if m.content == "stop" and m.author == author:
await self.client.say("%s has stopped *Who Is This Waifu?*" % (author))
channel_used_whoisthiswaifu[channel.id] = False
return
channel_used_whoisthiswaifu[channel.id] = False
##### WAIFU FROM WHAT ANIMU? #####
@commands.command(pass_context=True)
async def waifufromwhatanimu(self, ctx, dif : str = "m"):
if dif == "e":
waifus2cuck=waifus[-100:]
elif dif == "m":
waifus2cuck=waifus[-1000:]
elif dif == "h":
waifus2cuck=waifus[-8000:]
elif dif == "suicide":
waifus2cuck=waifus
channel = ctx.message.channel
author = ctx.message.author
print(dif)
if not channel.id in channel_used_waifufromwhatanimu:
channel_used_waifufromwhatanimu[channel.id] = True
else:
if channel_used_waifufromwhatanimu[channel.id] == True:
await self.client.say("You are already playing Waifu From What Animu, don't rush it.")
return
else:
channel_used_waifufromwhatanimu[channel.id] = True
while True:
waifu=waifus2cuck[random.randint(0, len(waifus2cuck)-1)]
animeName = waifu['series']['name']
waifuImg = waifu['display_picture']
await self.client.say("**Waifu From What Animu?**")
await self.client.say("*Type the name of the Anime/Series/Game of this waifu. Everyone in the channel can participate. Yay!*")
await self.client.send_file(channel, waifuImg)
await self.client.say("Type `next` for another animu (accessible by %s). \nType `stop` to end the cmd (accessible by %s)" % (author, author))
start = time.time()
while time.time()<(start+60):
print("inside while")
m = await self.client.wait_for_message(channel=channel, timeout=1)
print("pepe")
if time.time()>=(start+60):
await self.client.say("Oops! Nobody got it right. The name of the animu is %s." % (animeName))
channel_used_waifufromwhatanimu[channel.id] = False
return
if m is None:
continue
if (m.content).lower() ==(animeName).lower():
await self.client.say("Nice job! %s guessed the name right! The answer was %s" % (m.author, animeName))
break
if m.content == "next" and m.author == author:
break
if m.content == "stop" and m.author == author:
await self.client.say("%s has stopped *Waifu From What Animu?*" % (author))
channel_used_waifufromwhatanimu[channel.id] = False
return
channel_used_waifufromwhatanimu[channel.id] = False
def setup(client):
client.add_cog(trivia(client))