|
|
@@ -11,6 +11,9 @@ |
|
|
|
# TODO: WaifuRater - Mention user and RNG a rating |
|
|
|
# TODO: Admin tools - For commands already in and things like purge a chat |
|
|
|
# TODO: Overwatch stats - Using Overwatch-API lib |
|
|
|
# TODO: Move away from using ID's for everthing. Maybe replace list with dict |
|
|
|
# TODO: Add check for no channel id when a module is enabled |
|
|
|
|
|
|
|
|
|
|
|
import json |
|
|
|
import random |
|
|
@@ -21,7 +24,7 @@ from discord.ext.commands import Bot |
|
|
|
bot = Bot(command_prefix=".") |
|
|
|
# bot.remove_command("help") |
|
|
|
# TODO: Take these from a file, not the program |
|
|
|
token = '' |
|
|
|
token = 'MzA4MDc3ODg3MDYyNTQwMjg5.DEW5YA.JfLfU5jPjTFQi0xFI6B_-SKvC54' |
|
|
|
owner_id = "142735312626515979" |
|
|
|
|
|
|
|
config_template = { |
|
|
@@ -38,6 +41,14 @@ config_template = { |
|
|
|
"self-assign_roles": { |
|
|
|
"enabled": 0, |
|
|
|
"roles": [] |
|
|
|
}, |
|
|
|
"twitch_shilling": { |
|
|
|
"enabled": 0, |
|
|
|
"twitch-channel": "", |
|
|
|
"whitelist": { |
|
|
|
"enabled": 0, |
|
|
|
"list": [] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -69,7 +80,7 @@ def config_errorcheck(): |
|
|
|
|
|
|
|
|
|
|
|
def owner(ctx): |
|
|
|
if owner_id == ctx.author.id: |
|
|
|
if owner_id == ctx.message.author.id: |
|
|
|
return True |
|
|
|
else: |
|
|
|
return False |
|
|
@@ -100,19 +111,26 @@ async def on_ready(): |
|
|
|
# TODO: First part needs to be moved to wait_until_ready |
|
|
|
config_errorcheck() |
|
|
|
|
|
|
|
print("Client logged in\n\n") |
|
|
|
print("Servers I am currently in:\n") |
|
|
|
print("Client logged in\n") |
|
|
|
print("Servers I am currently in:") |
|
|
|
for server in bot.servers: |
|
|
|
print(server) |
|
|
|
print("") |
|
|
|
|
|
|
|
|
|
|
|
@bot.event |
|
|
|
async def on_member_update(before, after): |
|
|
|
if True: |
|
|
|
async def on_member_update(member_b, member_a): |
|
|
|
# Twitch Shilling Part |
|
|
|
if blacklisted(member_b): |
|
|
|
return |
|
|
|
for role in before.roles: |
|
|
|
print(role.name) |
|
|
|
for role in after.roles: |
|
|
|
print(role.name) |
|
|
|
|
|
|
|
ts_enabled = config[member_a.server.id]["twitch_shilling"]["enabled"] |
|
|
|
if ts_enabled: |
|
|
|
if not config[member_a.server.id]["twitch_shilling"]["whitelist"]["enabled"] or member_a.id in config[member_a.server.id]["twitch_shilling"]["whitelist"]["list"]: |
|
|
|
if member_a.game: |
|
|
|
if member_a.game.type: |
|
|
|
channel = discord.Object(config[member_a.server.id]["twitch_shilling"]["twitch-channel"]) |
|
|
|
return await bot.send_message(channel, content=":video_game:** {} is live!** :video_game:\n {}\n{}".format(member_a.name, member_a.game.name, member_a.game.url)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.event |
|
|
@@ -192,6 +210,52 @@ async def iam(ctx, role: discord.Role = None, *, user: discord.User = None, serv |
|
|
|
return await bot.say("That role is not self-assignable.") |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True, enabled=False) |
|
|
|
async def dice(ctx, num, *, user: discord.User = None): |
|
|
|
# TODO: Change to ndx format |
|
|
|
die = ("4","6","8","10","12","20","100") |
|
|
|
if num not in die: |
|
|
|
if num == "help": |
|
|
|
return await bot.say("!dice - This command random roles a dice. The die I support are (4, 6, 8, 10, 12, 20, 100) like the ones used in Table Top games.") |
|
|
|
else: |
|
|
|
return await bot.say("That is not a dice I know. Try !dice help for help!") |
|
|
|
user = mention_commandee(ctx) |
|
|
|
roll = dice_roll(int(num)) |
|
|
|
return await bot.say("You rolled a {}, {}".format(roll,user.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def suck(ctx, user: discord.User = None): |
|
|
|
if user is None: |
|
|
|
try: |
|
|
|
user = ctx.message.mentions[0] |
|
|
|
except: |
|
|
|
return await bot.say("You didn't mention someone for me to suck") |
|
|
|
return await bot.say(":eggplant: :sweat_drops: :tongue: {}".format(user.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(enabled=False) |
|
|
|
async def printcommands(): |
|
|
|
for command in bot.commands: |
|
|
|
print(command) |
|
|
|
return await bot.say("Done.") |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def listroles(ctx): |
|
|
|
roles = [] |
|
|
|
for role in config[ctx.message.server.id]["self-assign_roles"]["roles"]: |
|
|
|
for serverrole in ctx.message.server.roles: |
|
|
|
if role == serverrole.id: |
|
|
|
roles.append(serverrole.name) |
|
|
|
return await bot.say(roles) |
|
|
|
|
|
|
|
|
|
|
|
################# |
|
|
|
# Owner Commands# |
|
|
|
################# |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def blacklist(ctx, option, *mentions): |
|
|
|
""" |
|
|
@@ -208,7 +272,7 @@ async def blacklist(ctx, option, *mentions): |
|
|
|
mentions = ctx.message.mentions |
|
|
|
|
|
|
|
if not mentions: |
|
|
|
bot.say("You didn't mention anyone") |
|
|
|
return await bot.say("You didn't mention anyone") |
|
|
|
|
|
|
|
if option not in ['+', '-', 'add', 'remove']: |
|
|
|
return await bot.say('Invalid option "%s" specified, use +, -, add, or remove' % option, expire_in=20) |
|
|
@@ -232,9 +296,9 @@ async def blacklist(ctx, option, *mentions): |
|
|
|
if user.id not in lines: |
|
|
|
fp.write("{}\n".format(user.id)) |
|
|
|
blacklist_amount += 1 |
|
|
|
return await bot.say('{} users have been added to the blacklist'.format(blacklist_amount)) |
|
|
|
return await bot.say('{} user(s) have been added to the blacklist'.format(blacklist_amount)) |
|
|
|
|
|
|
|
else: |
|
|
|
elif option in ['-', 'remove']: |
|
|
|
with open("blacklist.txt","r") as fp: |
|
|
|
lines = fp.readlines() |
|
|
|
with open("blacklist.txt","w") as fp: |
|
|
@@ -245,60 +309,14 @@ async def blacklist(ctx, option, *mentions): |
|
|
|
else: |
|
|
|
fp.write("") |
|
|
|
blacklist_amount += 1 |
|
|
|
return await bot.say('{} users have been removed from the blacklist'.format(blacklist_amount)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True, enabled=False) |
|
|
|
async def dice(ctx, num, *, user: discord.User = None): |
|
|
|
# TODO: Change to ndx format |
|
|
|
die = ("4","6","8","10","12","20","100") |
|
|
|
if num not in die: |
|
|
|
if num == "help": |
|
|
|
return await bot.say("!dice - This command random roles a dice. The die I support are (4, 6, 8, 10, 12, 20, 100) like the ones used in Table Top games.") |
|
|
|
else: |
|
|
|
return await bot.say("That is not a dice I know. Try !dice help for help!") |
|
|
|
user = mention_commandee(ctx) |
|
|
|
roll = dice_roll(int(num)) |
|
|
|
return await bot.say("You rolled a {}, {}".format(roll,user.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def suck(ctx, user: discord.User = None): |
|
|
|
if user is None: |
|
|
|
try: |
|
|
|
user = ctx.message.mentions[0] |
|
|
|
except: |
|
|
|
return await bot.say("You didn't mention someone for me to suck") |
|
|
|
return await bot.say(":eggplant: :sweat_drops: :tongue: {}".format(user.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(enabled=False) |
|
|
|
async def printcommands(): |
|
|
|
for command in bot.commands: |
|
|
|
print(command) |
|
|
|
return await bot.say("Done.") |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def listroles(ctx): |
|
|
|
roles = [] |
|
|
|
for role in config[ctx.message.server.id]["self-assign_roles"]["roles"]: |
|
|
|
for serverrole in ctx.message.server.roles: |
|
|
|
if role == serverrole.id: |
|
|
|
roles.append(serverrole.name) |
|
|
|
return await bot.say(roles) |
|
|
|
|
|
|
|
|
|
|
|
################# |
|
|
|
# Owner Commands# |
|
|
|
################# |
|
|
|
return await bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def addrole(ctx, role: discord.Role = None): |
|
|
|
# Add Remove List Help |
|
|
|
if not owner: |
|
|
|
return |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
else: |
|
|
|
config[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) |
|
|
|
updateconfig() |
|
|
@@ -307,24 +325,20 @@ async def addrole(ctx, role: discord.Role = None): |
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def removerole(ctx, role: discord.Role = None): |
|
|
|
if not owner: |
|
|
|
return |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
|
|
|
|
count = 0 |
|
|
|
for sa_role in config[ctx.message.server.id]["self-assign_roles"]["roles"]: |
|
|
|
if sa_role == role.id: |
|
|
|
config[ctx.message.server.id]["self-assign_roles"]["roles"].pop(count) |
|
|
|
updateconfig() |
|
|
|
return await bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role))) |
|
|
|
else: |
|
|
|
count += 1 |
|
|
|
return await bot.say("That role was not in the list.") |
|
|
|
if role.id in config[ctx.message.server.id]["self-assign_roles"]["roles"]: |
|
|
|
config[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) |
|
|
|
return await bot.say('"{}" has been removed from the self-assignable roles.'.format(str(role))) |
|
|
|
else: |
|
|
|
return await bot.say("That role was not in the list.") |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def enablemodule(ctx, module): |
|
|
|
if not owner: |
|
|
|
return await bot.say("You ain't the owner, normie get out!!! REEE!") |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
else: |
|
|
|
if module in config[ctx.message.server.id]: |
|
|
|
if not config[ctx.message.server.id][module]["enabled"]: |
|
|
@@ -341,6 +355,8 @@ async def enablemodule(ctx, module): |
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def set_welcomechannel(ctx, channel: discord.Channel = None): |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
config[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id |
|
|
|
updateconfig() |
|
|
|
return await bot.say("{} has been set as the welcome channel!".format(channel.mention)) |
|
|
@@ -348,11 +364,69 @@ async def set_welcomechannel(ctx, channel: discord.Channel = None): |
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def set_goodbyechannel(ctx, channel: discord.Channel = None): |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
config[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id |
|
|
|
updateconfig() |
|
|
|
return await bot.say("{} has been set as the goodbye channel!".format(channel.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def set_twitchchannel(ctx, channel: discord.Channel = None): |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
config[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id |
|
|
|
updateconfig() |
|
|
|
return await bot.say("{} has been set as the twitch shilling channel!".format(channel.mention)) |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def ts_enablewhitelist(ctx): |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
else: |
|
|
|
if not config[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"]: |
|
|
|
config[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 1 |
|
|
|
updateconfig() |
|
|
|
return await bot.reply("Whitelist for Twitch shilling has been enabled.") |
|
|
|
else: |
|
|
|
config[ctx.server.id]["twitch_shilling"]["whitelist"]["enabled"] = 0 |
|
|
|
updateconfig() |
|
|
|
return await bot.reply("Whitelist for Twitch shilling has been disabled.") |
|
|
|
|
|
|
|
|
|
|
|
@bot.command(pass_context=True) |
|
|
|
async def ts_whitelist(ctx, option, *mentions): |
|
|
|
if not owner(ctx): |
|
|
|
return await bot.reply("You do not have permission to do this command.", delete_after=20) |
|
|
|
|
|
|
|
whitelist_count = 0 |
|
|
|
|
|
|
|
if not ctx.message.mentions and option != 'list': |
|
|
|
return await bot.reply("You haven't mentioned anyone to whitelist.") |
|
|
|
|
|
|
|
if option not in ['+', '-', 'add', 'remove', 'list']: |
|
|
|
return await bot.say('Invalid option "%s" specified, use +, -, add, or remove' % option, expire_in=20) |
|
|
|
|
|
|
|
if option in ['+', 'add']: |
|
|
|
for user in ctx.message.mentions: |
|
|
|
config[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].append(user.id) |
|
|
|
updateconfig() |
|
|
|
whitelist_count += 1 |
|
|
|
return await bot.say('{} user(s) have been added to the whitelist'.format(whitelist_count)) |
|
|
|
|
|
|
|
elif option in ['-', 'remove']: |
|
|
|
for user in ctx.message.mentions: |
|
|
|
if user.id in config[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]: |
|
|
|
config[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"].remove(user.id) |
|
|
|
updateconfig() |
|
|
|
whitelist_count += 1 |
|
|
|
return await bot.say('{} user(s) have been removed to the whitelist'.format(whitelist_count)) |
|
|
|
|
|
|
|
elif option == 'list': |
|
|
|
return await bot.say(config[ctx.message.server.id]["twitch_shilling"]["whitelist"]["list"]) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
config = load_config() |
|
|
|
bot.run(token) |