Browse Source

All visible commands have descriptions, new change avatar command, new announce command, new remove role command. also made some commands invisible.

tags/v0.3.0
roxie 7 years ago
parent
commit
fa6021f633
7 changed files with 140 additions and 30 deletions
  1. +66
    -16
      cogs/Admin.py
  2. +22
    -4
      cogs/Fun.py
  3. +2
    -2
      cogs/Twitch.py
  4. +43
    -4
      cogs/selfAssign.py
  5. +2
    -0
      config/config.py
  6. +1
    -1
      config/settings.ini
  7. +4
    -3
      main.py

+ 66
- 16
cogs/Admin.py View File

@@ -1,8 +1,10 @@
import sys
import os
import sys
import aiohttp
import asyncio

from config.config import Config
from main import owner_id
from config.config import Config

import discord
from discord.ext.commands import bot
@@ -17,7 +19,7 @@ class Admin():
self.bot = Bot
self.con = Config(Bot)

@bot.command(pass_context=True)
@bot.command(pass_context=True, hidden=True)
async def blacklist(self, ctx, option, *args):
"""
Usage:
@@ -28,7 +30,7 @@ class Admin():
Only the bot owner can use this command
"""
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
mentions = ctx.message.mentions

@@ -73,10 +75,10 @@ class Admin():
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):
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:
if module in self.con.serverconfig[ctx.message.server.id]:
if not self.con.serverconfig[ctx.message.server.id][setting]["enabled"]:
@@ -90,40 +92,88 @@ class Admin():
else:
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):
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.updateconfig(self.con.serverconfig)
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):
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.updateconfig(self.con.serverconfig)
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):
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.updateconfig(self.con.serverconfig)
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()
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()
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):
Bot.add_cog(Admin(Bot))

+ 22
- 4
cogs/Fun.py View File

@@ -1,6 +1,5 @@
import random

import discord
from discord.ext.commands import bot


@@ -10,6 +9,14 @@ class Fun():

@bot.command(pass_context=True)
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
dice = 0
if die[0].isdigit():
@@ -45,14 +52,24 @@ class Fun():
return await self.bot.say("{} rolled a **{}**".format(ctx.message.author.mention, roll))

@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:
return await self.bot.say("You didn't mention someone for me to suck")
user = ctx.message.mentions[0]
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):
"""
Rates the mentioned waifu(s)
Usage:
{command_prefix}waifurate @user#9999
"""
mentions = ctx.message.mentions
if not mentions:
return await self.bot.reply("You didn't mention anyone for me to rate.", delete_after=10)
@@ -76,8 +93,9 @@ class Fun():
else:
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):
"""Flip a coin"""
return await self.bot.reply("the coin landed on {}!".format(random.choice(["heads", "tails"])))



+ 2
- 2
cogs/Twitch.py View File

@@ -27,7 +27,7 @@ class Twitch():
content=":video_game:** {} is live!** :video_game:\n {}\n{}".format(
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):
if not owner(ctx):
return await self.bot.reply("You do not have permission to do this command.", delete_after=20)
@@ -41,7 +41,7 @@ class Twitch():
self.con.updateconfig(self.con.serverconfig)
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):
if not owner(ctx):
return await self.bot.reply("You do not have permission to do this command.", delete_after=20)

+ 43
- 4
cogs/selfAssign.py View File

@@ -14,8 +14,14 @@ class selfAssign():
self.bot = Bot
self.con = Config(Bot)


@bot.command(pass_context=True)
async def listroles(self, ctx):
"""
List's all roles that can be self-assigned on this server.
Usage:
{command_prefix}listroles
"""
roles = []
for role in self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"]:
for serverrole in ctx.message.server.roles:
@@ -25,6 +31,13 @@ class selfAssign():

@bot.command(pass_context=True)
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"]:
return

@@ -46,19 +59,45 @@ class selfAssign():
return await self.bot.say("That role is not self-assignable.")

@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):
# Add Remove List Help
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:
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].append(role.id)
self.con.updateconfig(self.con.serverconfig)
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):
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"]:
self.con.serverconfig[ctx.message.server.id]["self-assign_roles"]["roles"].remove(role.id)

+ 2
- 0
config/config.py View File

@@ -30,6 +30,8 @@ class Config():
}
self.serverconfig = self.load_config()
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):
self.serverconfig[server.id] = self.serverconfig_template["example"]

+ 1
- 1
config/settings.ini View File

@@ -1,6 +1,6 @@
[Credentials]
; Put your token here.
Token =
Token = MzA4MDc3ODg3MDYyNTQwMjg5.DEwCbA.Bj933S3guhHY4KnbtZyuwESJ_b4

[RoxBot]
OwnerID = 142735312626515979

+ 4
- 3
main.py View File

@@ -6,7 +6,8 @@
# 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: 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 #
# TODO: Move away from using ID's for everthing. Maybe replace list with dict
@@ -25,7 +26,7 @@ import configparser
import discord
from discord.ext.commands import Bot

from config import config
from config.config import Config
from cogs import cogs

__version__ = '0.3.0'
@@ -39,7 +40,7 @@ owner_id = settings["RoxBot"]["OwnerID"]
command_prefix = settings["RoxBot"]["CommandPrefix"]

bot = Bot(command_prefix=command_prefix)
con = config.Config(bot)
con = Config(bot)


def blacklisted(user):

Loading…
Cancel
Save