Exemplo n.º 1
0
import discord
from discord.ext import commands
import datetime

from mongo import db as mongo
from utils.process import readjson

speech = readjson('speech.json')
db = mongo.db


class EventHandler(commands.Cog):
    def __init__(self, bot):
        self.hidden = True

    @commands.Cog.listener()
    async def on_guild_join(self, guild):
        mongo.insert(guild, mongo.guildModel, db.guilds)

    @commands.Cog.listener()
    async def on_guild_remove(self, guild):
        mongo.remove(guild, db.guilds)

    # in the future, push guild id in array on insert, and check array length to determine removal.
    # only inserting to user db when required...
    @commands.Cog.listener()
    async def on_member_join(self, member):
        pass

    @commands.Cog.listener()
    async def on_member_remove(self, member):
Exemplo n.º 2
0
import discord
import re
import random
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions, BotMissingPermissions

from mongo import db
import utils.process as process

Config = process.readjson('config.json')
speech = process.readjson('speech.json')


class Fun(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.hidden = False
        self.name = 'Fun'

    @commands.command(hidden=False,
                      help=speech.help.say,
                      brief=speech.brief.say)
    async def say(self, ctx, *args):
        if not args:
            await ctx.send("Well? What do you want me to say?")
            return
        await ctx.send(" ".join(args))
        await ctx.message.delete()

    @commands.command(hidden=False,
                      help=speech.help.embed,
Exemplo n.º 3
0
import discord
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions, BotMissingPermissions

from mongo import db as mongo
from utils.process import readjson, mentionStrip
import re
import random
import mongo.db as db

Config = readjson('config.json')
speech = readjson('speech.json')

class Gifs(commands.Cog):  
    def __init__(self, bot): 
        self.bot = bot
        self.hidden = False
        self.name = 'Gifs'
    
    def gifCaption(self, ctx, target, resp, check):
        if not target:
            return resp.none.format(ctx.message.author.name), True
        try:
            targetid = mentionStrip(target[0])
            target = ctx.guild.get_member(targetid)
            
        except ValueError:
            return resp.err.format(ctx.message.author.name), True

        if target:
            if target.id == ctx.message.author.id:
Exemplo n.º 4
0
import discord
from discord.ext import commands
from datetime import date, datetime
from dotenv import load_dotenv
import os
import logging
import utils.process as process
from mongo import db

logging.basicConfig(level=logging.INFO)
Config = process.readjson('config.json')

load_dotenv()
TOKEN = os.getenv("TOKEN")

class Nia(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix=Config.prefix)
        #self.command_prefix = Config.prefix

bot = Nia()

# read and load cogs
bot.remove_command('help')
bot.remove_cog('general')
for file in os.listdir("cogs"):
    if file.endswith('.py'):
        name = file[:-3]
        bot.load_extension(f"cogs.{name}")
        
Exemplo n.º 5
0
Arquivo: checks.py Projeto: xmatea/Nia
from utils.process import readjson
config = readjson('config.json')


def isDev(ctx):
    return ctx.message.author.id in config.devs