import sys | |||||
import os | import os | ||||
import sys | |||||
import aiohttp | |||||
import asyncio | |||||
from config.config import Config | |||||
from main import owner_id | from main import owner_id | ||||
from config.config import Config | |||||
import discord | import discord | ||||
from discord.ext.commands import bot | from discord.ext.commands import bot | ||||
self.bot = Bot | self.bot = Bot | ||||
self.con = Config(Bot) | self.con = Config(Bot) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def blacklist(self, ctx, option, *args): | async def blacklist(self, ctx, option, *args): | ||||
""" | """ | ||||
Usage: | Usage: | ||||
Only the bot owner can use this command | Only the bot owner can use this command | ||||
""" | """ | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
blacklist_amount = 0 | blacklist_amount = 0 | ||||
mentions = ctx.message.mentions | mentions = ctx.message.mentions | ||||
return await self.bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount)) | return await self.bot.say('{} user(s) have been removed from the blacklist'.format(blacklist_amount)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def enablesetting(self, ctx, setting): | async def enablesetting(self, ctx, setting): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
else: | else: | ||||
if module in self.con.serverconfig[ctx.message.server.id]: | if module in self.con.serverconfig[ctx.message.server.id]: | ||||
if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]: | if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]: | ||||
else: | else: | ||||
return await self.bot.say("That module dont exist fam. You made the thing") | return await self.bot.say("That module dont exist fam. You made the thing") | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def set_welcomechannel(self, ctx, channel: discord.Channel = None): | async def set_welcomechannel(self, ctx, channel: discord.Channel = None): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id | self.con.serverconfig[ctx.message.server.id]["greets"]["welcome-channel"] = channel.id | ||||
self.con.updateconfig(self.con.serverconfig) | self.con.updateconfig(self.con.serverconfig) | ||||
return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention)) | return await self.bot.say("{} has been set as the welcome channel!".format(channel.mention)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def set_goodbyechannel(self, ctx, channel: discord.Channel = None): | async def set_goodbyechannel(self, ctx, channel: discord.Channel = None): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id | self.con.serverconfig[ctx.message.server.id]["goodbyes"]["goodbye-channel"] = channel.id | ||||
self.con.updateconfig(self.con.serverconfig) | self.con.updateconfig(self.con.serverconfig) | ||||
return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention)) | return await self.bot.say("{} has been set as the goodbye channel!".format(channel.mention)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def set_twitchchannel(self, ctx, channel: discord.Channel = None): | async def set_twitchchannel(self, ctx, channel: discord.Channel = None): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id | self.con.serverconfig[ctx.message.server.id]["twitch_shilling"]["twitch-channel"] = channel.id | ||||
self.con.updateconfig(self.con.serverconfig) | self.con.updateconfig(self.con.serverconfig) | ||||
return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention)) | return await self.bot.say("{} has been set as the twitch shilling channel!".format(channel.mention)) | ||||
@bot.command() | |||||
async def restart(self): | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def changeavatar(self, ctx, url=None): | |||||
""" | |||||
Usage: | |||||
{command_prefix}setavatar [url] | |||||
Changes the bot's avatar. | |||||
Attaching a file and leaving the url parameter blank also works. | |||||
""" | |||||
if not owner(ctx): | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
if ctx.message.attachments: | |||||
thing = ctx.message.attachments[0]['url'] | |||||
else: | |||||
thing = url.strip('<>') | |||||
tempAvaFile = 'tempAva.png' | |||||
async with aiohttp.get(thing) as img: | |||||
with open(tempAvaFile, 'wb') as f: | |||||
f.write(await img.read()) | |||||
with open(tempAvaFile, 'rb') as f: | |||||
await self.bot.edit_profile(avatar=f.read()) | |||||
os.remove(tempAvaFile) | |||||
asyncio.sleep(2) | |||||
return await self.bot.say(":ok_hand:") | |||||
@bot.command(hidden=True) | |||||
async def restart(self, ctx): | |||||
if not owner(ctx): | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
await self.bot.logout() | await self.bot.logout() | ||||
return os.execl(sys.executable, sys.executable, *sys.argv) | return os.execl(sys.executable, sys.executable, *sys.argv) | ||||
@bot.command() | |||||
async def shutdown(self): | |||||
@bot.command(hidden=True) | |||||
async def shutdown(self, ctx): | |||||
if not owner(ctx): | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
await self.bot.logout() | await self.bot.logout() | ||||
return exit(0) | return exit(0) | ||||
@bot.command(pass_context=True, hidden=True) | |||||
async def announce(self, ctx, *announcement): | |||||
""" | |||||
ONLY USE FOR SERIOUS ANNOUNCEMENTS | |||||
""" | |||||
if not owner(ctx): | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
embed = discord.Embed(title="RoxBot Announcement", colour=discord.Colour(0x306f99), description=' '.join(announcement)) | |||||
embed.set_footer(text="This message has be automatically generated by a QT Roxie", | |||||
icon_url=self.bot.user.avatar_url) | |||||
for server in self.bot.servers: | |||||
await self.bot.send_message(server, embed=embed) | |||||
return await self.bot.say("Done!", delete_after=self.con.delete_after) | |||||
def setup(Bot): | def setup(Bot): | ||||
Bot.add_cog(Admin(Bot)) | Bot.add_cog(Admin(Bot)) |
import random | import random | ||||
import discord | |||||
from discord.ext.commands import bot | from discord.ext.commands import bot | ||||
@bot.command(pass_context=True) | @bot.command(pass_context=True) | ||||
async def roll(self, ctx, die): | async def roll(self, ctx, die): | ||||
""" | |||||
Rolls a die using ndx format. | |||||
Usage: | |||||
{command_prefix}roll ndx | |||||
Example: | |||||
.roll 2d20 # Rolls two D20s | |||||
""" | |||||
# TODO: Change to ndx format | # TODO: Change to ndx format | ||||
dice = 0 | dice = 0 | ||||
if die[0].isdigit(): | if die[0].isdigit(): | ||||
return await self.bot.say("{} rolled a **{}**".format(ctx.message.author.mention, roll)) | return await self.bot.say("{} rolled a **{}**".format(ctx.message.author.mention, roll)) | ||||
@bot.command(pass_context=True) | @bot.command(pass_context=True) | ||||
async def suck(self, ctx, user: discord.User = None): | |||||
async def suck(self, ctx): | |||||
""" | |||||
Sucks the mentioned user ;) | |||||
Usage: | |||||
{command_prefix}suck @user#9999 | |||||
""" | |||||
if len(ctx.message.mentions) < 1: | if len(ctx.message.mentions) < 1: | ||||
return await self.bot.say("You didn't mention someone for me to suck") | return await self.bot.say("You didn't mention someone for me to suck") | ||||
user = ctx.message.mentions[0] | user = ctx.message.mentions[0] | ||||
return await self.bot.say(":eggplant: :sweat_drops: :tongue: {}".format(user.mention)) | return await self.bot.say(":eggplant: :sweat_drops: :tongue: {}".format(user.mention)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, aliases=["wf"]) | |||||
async def waifurate(self, ctx): | async def waifurate(self, ctx): | ||||
""" | |||||
Rates the mentioned waifu(s) | |||||
Usage: | |||||
{command_prefix}waifurate @user#9999 | |||||
""" | |||||
mentions = ctx.message.mentions | mentions = ctx.message.mentions | ||||
if not mentions: | if not mentions: | ||||
return await self.bot.reply("You didn't mention anyone for me to rate.", delete_after=10) | return await self.bot.reply("You didn't mention anyone for me to rate.", delete_after=10) | ||||
else: | else: | ||||
return await self.bot.say("Oh that's your waifu? I rate them a {}/10. {}".format(rating, emoji)) | return await self.bot.say("Oh that's your waifu? I rate them a {}/10. {}".format(rating, emoji)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, aliases=["cf"]) | |||||
async def coinflip(self, ctx): | async def coinflip(self, ctx): | ||||
"""Flip a coin""" | |||||
return await self.bot.reply("the coin landed on {}!".format(random.choice(["heads", "tails"]))) | return await self.bot.reply("the coin landed on {}!".format(random.choice(["heads", "tails"]))) | ||||
content=":video_game:** {} is live!** :video_game:\n {}\n{}".format( | content=":video_game:** {} is live!** :video_game:\n {}\n{}".format( | ||||
member_a.name, member_a.game.name, member_a.game.url)) | member_a.name, member_a.game.name, member_a.game.url)) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def ts_enablewhitelist(self, ctx): | async def ts_enablewhitelist(self, ctx): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | ||||
self.con.updateconfig(self.con.serverconfig) | self.con.updateconfig(self.con.serverconfig) | ||||
return await self.bot.reply("Whitelist for Twitch shilling has been disabled.") | return await self.bot.reply("Whitelist for Twitch shilling has been disabled.") | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def ts_whitelist(self, ctx, option, *mentions): | async def ts_whitelist(self, ctx, option, *mentions): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | return await self.bot.reply("You do not have permission to do this command.", delete_after=20) |
self.bot = Bot | self.bot = Bot | ||||
self.con = Config(Bot) | self.con = Config(Bot) | ||||
@bot.command(pass_context=True) | @bot.command(pass_context=True) | ||||
async def listroles(self, ctx): | async def listroles(self, ctx): | ||||
""" | |||||
List's all roles that can be self-assigned on this server. | |||||
Usage: | |||||
{command_prefix}listroles | |||||
""" | |||||
roles = [] | roles = [] | ||||
for role in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | for role in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | ||||
for serverrole in ctx.message.server.roles: | for serverrole in ctx.message.server.roles: | ||||
@bot.command(pass_context=True) | @bot.command(pass_context=True) | ||||
async def iam(self, ctx, role: discord.Role = None): | async def iam(self, ctx, role: discord.Role = None): | ||||
""" | |||||
Self-assign yourself a role. Only one role at a time. Doesn't work for roles with spaces. | |||||
Usage: | |||||
{command_prefix}iam [role] | |||||
Example: | |||||
.iam OverwatchPing | |||||
""" | |||||
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: | if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: | ||||
return | return | ||||
return await self.bot.say("That role is not self-assignable.") | return await self.bot.say("That role is not self-assignable.") | ||||
@bot.command(pass_context=True) | @bot.command(pass_context=True) | ||||
async def iamn(self, ctx, role: discord.Role = None): | |||||
""" | |||||
Remove a self-assigned role | |||||
Usage: | |||||
{command_prefix}iamn [role] | |||||
Example: | |||||
.iamn OverwatchPing | |||||
""" | |||||
if not self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["enabled"]: | |||||
return | |||||
user = ctx.message.author | |||||
server = ctx.message.server | |||||
if role not in server.roles: | |||||
return await self.bot.say("That role doesn't exist. Roles are case sensitive. ") | |||||
elif role in user.roles and role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | |||||
await self.bot.remove_roles(user, role) | |||||
return await self.bot.reply("{} has been successfully removed.".format(role.name)) | |||||
elif role not in user.roles and role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | |||||
return await self.bot.reply("You do not have {}.".format(role.name)) | |||||
else: | |||||
return await self.bot.say("That role is not self-assignable.") | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def addrole(self, ctx, role: discord.Role = None): | async def addrole(self, ctx, role: discord.Role = None): | ||||
# Add Remove List Help | |||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
else: | else: | ||||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) | self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id) | ||||
self.con.updateconfig(self.con.serverconfig) | self.con.updateconfig(self.con.serverconfig) | ||||
return await self.bot.say('Role "{}" added'.format(str(role))) | return await self.bot.say('Role "{}" added'.format(str(role))) | ||||
@bot.command(pass_context=True) | |||||
@bot.command(pass_context=True, hidden=True) | |||||
async def removerole(self, ctx, role: discord.Role = None): | async def removerole(self, ctx, role: discord.Role = None): | ||||
if not owner(ctx): | if not owner(ctx): | ||||
return await self.bot.reply("You do not have permission to do this command.", delete_after=20) | |||||
return await self.bot.reply(self.con.no_perms_reponse, delete_after=self.con.delete_after) | |||||
if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | if role.id in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]: | ||||
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) | self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id) |
} | } | ||||
self.serverconfig = self.load_config() | self.serverconfig = self.load_config() | ||||
self.bot = bot | self.bot = bot | ||||
self.no_perms_reponse = ":no_entry_sign: You do not have permission to use this command." | |||||
self.delete_after = 20 | |||||
async def on_server_join(self, server): | async def on_server_join(self, server): | ||||
self.serverconfig[server.id] = self.serverconfig_template["example"] | self.serverconfig[server.id] = self.serverconfig_template["example"] |
[Credentials] | [Credentials] | ||||
; Put your token here. | ; Put your token here. | ||||
Token = | |||||
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DEwCbA.Bj933S3guhHY4KnbtZyuwESJ_b4 | |||||
[RoxBot] | [RoxBot] | ||||
OwnerID = 142735312626515979 | OwnerID = 142735312626515979 |
# TODO: Command Review, look at all commands and flesh them out. Maybe some randomised dialogue so that not every command has only one response. Make sure user experience feels nice. | # TODO: Command Review, look at all commands and flesh them out. Maybe some randomised dialogue so that not every command has only one response. Make sure user experience feels nice. | ||||
# TODO: Also self delete timers. | # TODO: Also self delete timers. | ||||
# TODO: Full Docs on the commands and their use | # TODO: Full Docs on the commands and their use | ||||
# TODO: Complete rework of the commands. Moving to cog based commands again. Rework the code to be easier and cleaner. | |||||
# TODO: iam remove command | |||||
# TODO: Welcome and goodbye default messages and changable messages | |||||
# Mid Priority # | # Mid Priority # | ||||
# TODO: Move away from using ID's for everthing. Maybe replace list with dict | # TODO: Move away from using ID's for everthing. Maybe replace list with dict | ||||
import discord | import discord | ||||
from discord.ext.commands import Bot | from discord.ext.commands import Bot | ||||
from config import config | |||||
from config.config import Config | |||||
from cogs import cogs | from cogs import cogs | ||||
__version__ = '0.3.0' | __version__ = '0.3.0' | ||||
command_prefix = settings["RoxBot"]["CommandPrefix"] | command_prefix = settings["RoxBot"]["CommandPrefix"] | ||||
bot = Bot(command_prefix=command_prefix) | bot = Bot(command_prefix=command_prefix) | ||||
con = config.Config(bot) | |||||
con = Config(bot) | |||||
def blacklisted(user): | def blacklisted(user): |