-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
300 lines (252 loc) · 10.2 KB
/
main.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# ***************************************************************************#
# #
# Toonbot - A Toontown Themed Discord Bot. #
# #
# ***************************************************************************#
import aiohttp
import box
import datetime
import discord
import json
import random
import os
import platform
import requests
import time
from dadjokes import Dadjoke
from discord.ext import commands
from datetime import datetime
from discord.ext.commands import CommandNotFound
prefix = "toon: "
intents = discord.Intents.default()
intents.members = True
playing = [
"Corporate Crash", "tewtow onlin",
"old toontown download free working 100%", "litigator head model",
"toontown rewritten field offices leak", "Among Us (in real life)", "cuh...", "watch yo tone"
]
client = commands.Bot(description="Toonbot",
command_prefix=prefix,
intents=intents,
activity=discord.Game(name=random.choice(playing)))
client.remove_command('help')
# Owner ID
ownerID = 543576276108181506
owner2ID = 353615061169995779
@client.event
async def on_ready():
memberCount = len(set(client.get_all_members()))
serverCount = len(client.guilds)
print(" ")
print("################################################################")
print(f" ______ __ __ ")
print(f" /_ __/___ ____ ____ / /_ ____ / /_ ")
print(f" / / / __ \/ __ \/ __ \/ __ \/ __ \/ __/ ")
print(f" / / / /_/ / /_/ / / / / /_/ / /_/ / /_ ")
print(f" /_/ \____/\____/_/ /_/_.___/\____/\__/ ")
print(" ")
print("################################################################")
print(" ")
print("Running as: " + client.user.name + "#" + client.user.discriminator)
print(f'With Client ID: {client.user.id}')
print("\nBuilt With:")
print("Python " + platform.python_version())
print("Discord.py " + discord.__version__)
# Help Command
@client.command()
async def help(ctx):
embed = discord.Embed(color=discord.Color.orange())
# General Comamnds
embed.add_field(
name="General",
value=
"{}help - Shows This Message\n\n {}ping - Says Pong Back To You\n\n {}server - Shows Server Info\n\n {}stats "
"- Show Bot Stats "
.format(prefix, prefix, prefix, prefix),
inline=False)
# Fun Comamnds
embed.add_field(
name="Fun",
value=
"{}toss - Coin Flip\n\n {}joke - Give a Dad Joke\n\n {}dice - Roll 1-6\n\n {}reverse - <text> Reverses the "
"given text\n\n {}poll <name> - starts a poll\n\n {}sus - sees how sus you are "
.format(prefix, prefix, prefix, prefix, prefix, prefix),
inline=False)
embed.add_field(
name="Reddit/API Commands",
value=
"{}meme - Gives a random meme from r/memes.\n\n {}r/toontown - shows a random post from the Toontown "
"subreddit.\n\n {}r/toontownrewritten - shows a random post from the Toontown Rewritten subreddit.\n\n {"
"}ttrdistricts - Gives you a list of ttr distrcts "
.format(prefix, prefix, prefix, prefix),
inline=False)
await ctx.reply("A list of commands.", embed=embed)
# Ping Command
@client.command()
async def ping(ctx):
"""Ping Pong"""
await ctx.reply('Pong!')
# Roll Dice Command
@client.command(aliases=["roll"])
async def dice(ctx):
"""Rolls the dice"""
cont = random.randint(1, 6)
await ctx.reply("You Rolled **{}**".format(cont))
# Coin Flip Command
@client.command(aliases=["flip"])
async def toss(ctx):
"""Put the toss"""
ch = ["Heads", "Tails"]
rch = random.choice(ch)
await ctx.reply(f"You got **{rch}**")
# Reverse Text Command
@client.command()
async def reverse(ctx, *, text):
"""Reverse the given text"""
await ctx.reply("".join(list(reversed(str(text)))))
# sussy command
@client.command()
async def sus(ctx):
"""sees how sus you are"""
susrates = "you are very sus :sussy: ", "you are kinda sus... maybe we have an imposter among us ", "you arent sus (you won)"
await ctx.reply(random.choice(susrates))
# Meme Command
@client.command()
async def meme(ctx):
"""Sends you random meme"""
r = await aiohttp.ClientSession().get(
"https://www.reddit.com/r/dankmemes/top.json?sort=new&t=day&limit=100")
r = await r.json()
r = box.Box(r)
data = random.choice(r.data.children).data
img = data.url
title = data.title
url_base = data.permalink
url = "https://reddit.com" + url_base
embed = discord.Embed(title=title, url=url, color=discord.Color.blurple())
embed.set_image(url=img)
await ctx.reply(embed=embed)
# r/Toontown Command Command
@client.command(aliases=['r/toontown'])
async def rtoontown(ctx):
"""Sends you a random post from r/toontown"""
r = await aiohttp.ClientSession().get(
"https://www.reddit.com/r/toontown.json?sort=new&t=day&limit=100")
r = await r.json()
r = box.Box(r)
data = random.choice(r.data.children).data
img = data.url
title = data.title
url_base = data.permalink
url = "https://reddit.com" + url_base
embed = discord.Embed(title=title, url=url, color=discord.Color.blurple())
embed.set_image(url=img)
await ctx.reply(embed=embed)
# r/ToontownRewritten Command
@client.command(aliases=['r/toontownrewritten'])
async def rtoontownrewritten(ctx):
"""Sends you a random post from r/toontownrewritten"""
r = await aiohttp.ClientSession().get(
"https://www.reddit.com/r/toontownrewritten.json?sort=new&t=day&limit=100"
)
r = await r.json()
r = box.Box(r)
data = random.choice(r.data.children).data
img = data.url
title = data.title
url_base = data.permalink
url = "https://reddit.com" + url_base
embed = discord.Embed(title=title, url=url, color=discord.Color.blurple())
embed.set_image(url=img)
await ctx.reply(embed=embed)
# Dad-joke Command
@client.command(aliases=["dadjoke"])
async def joke(ctx):
"""Sends the dadjokes"""
async with ctx.typing():
await ctx.reply(Dadjoke().joke)
@client.command("server")
async def s_info(ctx):
server = ctx.guild
icon = ("\uFEFF")
embed = discord.Embed(title=f"Server info for {server.name}",
description='\uFEFF',
colour=0x98FB98,
timestamp=ctx.message.created_at)
embed.set_thumbnail(url=server.icon_url(size=256))
embed.add_field(name="Name", value=server.name, inline=True)
embed.add_field(name="Region", value=server.region, inline=True)
embed.add_field(name="Member Count",
value=server.member_count,
inline=True)
embed.add_field(name="Owner",
value="<@" + f"{server.owner_id}" + ">",
inline=True)
embed.add_field(name="ID", value=server.id, inline=True)
embed.add_field(name="Creation Date",
value=f"{server.created_at}",
inline=True)
embed.add_field(name="Server Icon Url", value=server.icon_url, inline=True)
await ctx.reply(content=None, embed=embed)
# Stats Command
@client.command()
async def stats(ctx):
pythonVersion = platform.python_version()
dpyVersion = discord.__version__
serverCount = len(client.guilds)
memberCount = len(set(client.get_all_members()))
embed = discord.Embed(title=f'{client.user.name} Stats',
description='\uFEFF',
colour=0x98FB98,
timestamp=ctx.message.created_at)
embed.add_field(name='Python Version:',
value=f"{pythonVersion}",
inline=False)
embed.add_field(name='Discord.py Version',
value=f"{dpyVersion}",
inline=False)
embed.add_field(name='Total Guilds:', value=f"{serverCount}", inline=False)
embed.add_field(name='Total Users:', value=f"{memberCount}", inline=False)
embed.add_field(name='Bot Developers:',
value="<@" + f"{ownerID}" + ">, "
"<@" + f"{owner2ID}" + ">",
inline=False)
embed.set_footer(text=f"Yours truly, {client.user.name}")
await ctx.reply(embed=embed)
print("complete")
# Poll Command
@client.command(pass_context=True)
async def poll(ctx, *args):
msg = ' '.join(args)
embed = discord.Embed(title='A Poll has Started !',
description='{0}'.format(msg),
color=0x00FF00)
embed.set_footer(text='Poll created by: {0} • React to vote!'.format(
ctx.message.author))
embed_message = await ctx.reply(embed=embed)
await embed_message.add_reaction('👍')
await embed_message.add_reaction('👎')
await embed_message.add_reaction('🤷')
# TTRDistricts commands
@client.command(pass_context=True)
async def ttrdistricts(ctx):
embed = discord.Embed(color=discord.Color.orange())
ttr_districts_api = "https://www.toontownrewritten.com/api/population"
ttr_districts_response = requests.get(ttr_districts_api, verify=True)
ttr_districts_json = ttr_districts_response.json()
ttr_districts = ttr_districts_json["populationByDistrict"]
ttr_districts = json.dumps(ttr_districts, sort_keys=True, indent=2)
ttr_districts = ttr_districts.replace('"', '')
ttr_districts = ttr_districts.replace(',', '')
ttr_districts = str(ttr_districts)[1:-2]
embed.add_field(name="Toontown Rewritten Districts",
value=ttr_districts
)
await ctx.reply(embed=embed)
@client.event
async def on_command_error(ctx, error):
if isinstance(error, CommandNotFound):
await ctx.reply("That Command Was not found!")
# Run Bot
TOKEN = os.environ.get("TOKEN")
client.run(TOKEN)