-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmewtwo.py
182 lines (156 loc) · 7.94 KB
/
mewtwo.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
import nextcord
from nextcord.ext import tasks, commands
import asyncio
import random
import traceback
import sys
import datetime
import mewtwo_config as config
print('Starting Mewtwo.py... This may take some time.')
print('')
intents = nextcord.Intents.all()
bot = commands.Bot(command_prefix='>', intents=intents, owner_id=config.owner, case_insensitive=True)
cogs = ["cogs.general", "cogs.fun", "cogs.nsfw", "cogs.other", "cogs.admin"]
start_time = datetime.datetime.utcnow()
botver = "Mewtwo v2.1"
botstatus = [
'with >help',
'Now using Nextcord!',
'try >help!',
'try >google!',
'try >info!',
'try >define!',
'try >avatar!',
'try >sylveon!',
'try >meloetta!',
'try >bunny!',
'in the Kanto region!',
'in Cerulean Cave',
'Pokémon Red',
'Pokémon Green',
'Pokémon Blue',
'Pokémon Yellow',
'with hugs! 🤗',
'with bunnies! 🐇',
'with Mew under the truck',
'with Mega Evolution',
'as Mega Mewtwo X',
'as Mega Mewtwo Y',
]
@bot.event
async def on_ready():
dev = bot.get_user(config.owner)
for c in cogs:
bot.load_extension(c)
print('Mewtwo, now using Nextcord!')
print(f'v2.1 by {dev.name}#{dev.discriminator} - Support: https://discord.gg/kDC9tW7')
print(f'Logged into: {bot.user.name}#{bot.user.discriminator}')
print('------')
@tasks.loop(minutes=10.0)
async def change_status():
playing = random.choice(botstatus)
await bot.change_presence(activity=nextcord.Game(name=playing))
@change_status.before_loop
async def before_change_status():
await bot.wait_until_ready()
@bot.command()
@commands.is_owner()
async def shutdown(ctx):
await ctx.send(":wave: Done! See ya!")
await bot.close()
@bot.command()
@commands.is_owner()
async def reload(ctx):
for c in cogs:
bot.unload_extension(c)
bot.load_extension(c)
await ctx.send(":white_check_mark: Successfully reloaded all cogs!")
@bot.command(aliases=["say"])
@commands.cooldown(5, 5, commands.BucketType.user)
async def echo(ctx, *, arg):
if ctx.message.mention_everyone:
return await ctx.send(":x: Sorry, you may not tag everyone/here in this command.")
elif ctx.message.raw_mentions:
return await ctx.send(":x: Sorry, you may not tag other users in this command.")
if ctx.message.raw_role_mentions:
return await ctx.send(":x: Sorry, you may not tag roles in this command.")
elif '@everyone' in ctx.message.content:
return await ctx.send(":x: Sorry, you may not tag everyone/here in this command.")
elif '@here' in ctx.message.content:
return await ctx.send(":x: Sorry, you may not tag everyone/here in this command.")
else:
await ctx.message.delete()
await ctx.send(arg)
@bot.command()
async def info(ctx):
dev = bot.get_user(config.owner)
now = datetime.datetime.utcnow() # Timestamp of when uptime function is run
delta = now - start_time
hours, remainder = divmod(int(delta.total_seconds()), 3600)
minutes, seconds = divmod(remainder, 60)
days, hours = divmod(hours, 24)
if days:
time_format = "**{d}** days, **{h}** hours, **{m}** minutes, and **{s}** seconds."
else:
time_format = "**{h}** hours, **{m}** minutes, and **{s}** seconds."
uptime_stamp = time_format.format(d=days, h=hours, m=minutes, s=seconds)
embed = nextcord.Embed(title=botver, description="A Discord bot by PrincessLillie. It's a little project I've been working on for some time. A few people like it, but I'm not sure why!\nWant to invite me to your server? [You can do so here!](https://discordapp.com/oauth2/authorize?client_id=442154636028280843&scope=bot&permissions=8&redirect_uri=https%3A%2F%2Fsks316.github.io%2Fmewtwo%2Fthanks&response_type=code&prompt=none) Don't want to give me administrator permissions? Use [this invite link](https://discordapp.com/oauth2/authorize?client_id=442154636028280843&scope=bot&permissions=388160&redirect_uri=https%3A%2F%2Fsks316.github.io%2Fmewtwo%2Fthanks&response_type=code&prompt=none) instead. (You may need to manually edit my permissions if new features are added though...)", color=0x8253c3)
embed.add_field(name="Made by:", value=f"{dev.name}#{dev.discriminator}")
embed.add_field(name="This bot is currently in:", value=f"{len(bot.guilds)} server(s)")
embed.add_field(name="Source Code:", value="You can view Mewtwo's source code on [GitHub](https://github.com/sks316/mewtwo-bot)!", inline=False)
embed.add_field(name="Uptime:", value="Mewtwo has been online for {}".format(uptime_stamp), inline=False)
embed.add_field(name="Support Server:", value="[Mewtwo Dev](https://discord.gg/kDC9tW7)")
embed.set_footer(text=f"{botver} by PrincessLillie", icon_url='https://sks316.s-ul.eu/bsHvTCLJ')
await ctx.send(embed=embed)
bot.remove_command('help')
@bot.event
async def on_command_error(ctx, error):
if hasattr(ctx.command, 'on_error'):
return
ignored = (commands.CommandNotFound)
error = getattr(error, 'original', error)
if isinstance(error, ignored):
return
elif isinstance(error, commands.DisabledCommand):
err = await ctx.send(f':x: Sorry, **{ctx.command}** has been disabled.')
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
elif isinstance(error, commands.UserInputError):
err = await ctx.send(f':x: Please provide a valid argument and try again. For example, **>{ctx.command} Mewtwo**.')
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
elif isinstance(error, commands.NotOwner):
err = await ctx.send(f':x: Sorry, you are not permitted to use the command **{ctx.command}**.')
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
elif isinstance(error, commands.CommandOnCooldown):
err = await ctx.send(":x: Sorry, you're being ratelimited for this command. Try again in **{:.2f}".format(error.retry_after) + "** seconds.")
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
elif isinstance(error, nextcord.Forbidden):
err = await ctx.send(f":x: I don't have sufficient permissions to do something. If you tried running **>help**, make sure your DMs are open. Otherwise, please have an administrator check my permissions.")
await ctx.message.delete(delay=10)
return await err.delete(delay=10)
elif isinstance(error, commands.NSFWChannelRequired):
err = await ctx.send(f":x: You'll, uh, have to run that one in an NSFW channel.")
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
elif isinstance(error, commands.NoPrivateMessage):
try:
err = await ctx.author.send(f':x: Sorry, **{ctx.command}** can not be used in Private Messages.')
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
except:
pass
elif isinstance(error, commands.BadArgument):
if ctx.command.qualified_name == 'tag list':
err = await ctx.send(':x: I could not find that member. Please try again.')
await ctx.message.delete(delay=5)
return await err.delete(delay=5)
print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
err = await ctx.send(':x: Sorry, an unknown error occurred. Please use **>bug** to submit a bug report. Make sure you provide as many details as possible. \nYou can also join Mewtwo Dev to submit bug reports. **>info** contains an invite.')
await ctx.message.delete(delay=10)
await err.delete(delay=10)
change_status.start()
bot.run(config.token)