-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselfbot.py
68 lines (57 loc) · 2.56 KB
/
selfbot.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
from discord import Client
from asyncio import sleep
from random import randint
import config
from importlib import import_module # Using importlib's `import_module` function is preferred over Python's built-in `__import__`
bot = Client()
commands = {}
for file in import_module('os').listdir(import_module('os').path.join('.', 'cmds')):
if file.endswith('.py'):
cmd = import_module("cmds."+file[:-3])
# The following code is going to check if the command is valid, if it is, then register it
if not isinstance(cmd.aliases, list):
print("Command alias is not a list, skipping "+file)
elif not isinstance(cmd.name, str):
print("Command name is not a string, skipping "+file)
if (isinstance(cmd.aliases, list) and isinstance(cmd.name, str)):
for alias in cmd.aliases:
commands[alias] = {"code":cmd.code, "alias":True, "original_name":cmd.name}
commands[cmd.name] = {"code":cmd.code, "alias":False, "original_name":cmd.name}
enabled_channels = []
class temp:
async def embed(msg, args):
try:
if args[0] == '':
args[0] = None
if args[1] == '':
args[1] = None
hex=eval(args[2])
except IndexError:
hex=randint(0,16777215)
try:
await msg.channel.send(embed=discord.Embed(title=args[1], description=args[0], colour=hex))
except IndexError:
try:
await msg.channel.send(embed=discord.Embed(description=args[0], colour=hex))
except IndexError:
await msg.channel.send(embed=discord.Embed(colour=hex))
@bot.event
async def on_message(msg):
if msg.author.id == bot.user.id and msg.content == '/enable_channel' and msg.channel not in enabled_channels:
enabled_channels.append(msg.channel)
print("Channel added to enabled channels list")
elif msg.author.id not in config.allowed_ids+[bot.user.id] and msg.content == '/disable_channel' and msg.channel in enabled_channels:
enabled_channels.pop(enabled_channels.index(msg.channel))
if msg.author.id not in config.allowed_ids+[bot.user.id]:
if config.enabled_by_default != True:
return
try:
for cmd in commands:
if msg.content.startswith(config.prefix+cmd):
msg.args = msg.content[len(config.prefix+cmd+" "):].split(config.splitter)
await commands[cmd](msg)
else:
return
except KeyError:
pass
bot.run(config.token, bot=False)