Exemplo n.º 1
0
    async def coven(self, ctx):
        """Notifications for games"""

        channel = ctx.message.channel
        channelid = str(channel.id)
        authorid = str(ctx.message.author.id)
        covennotifs = discord.Role(id='358655924342095874', server='288455332173316106')
        senior = discord.Role(id='288464565791096838', server='288455332173316106')
        mod = discord.Role(id='288682024515141634', server='288455332173316106')
        gmn = discord.Role(id='358401178909933568', server='288455332173316106')
        temp = discord.Role(id='465973033106931713', server='288455332173316106')

        if channelid in ['358331904233046016', '358660402462326784', '288463362357067777', '288455332173316106',
                         '296069608216068098']:
            if ctx.invoked_subcommand is None:
                if senior or mod or gmn or temp in ctx.message.author.roles:
                    await self.bot.say('`/coven host` or `/coven final` or `/coven gamemodes`')
                elif covennotifs in ctx.message.author.roles:
                    await self.bot.say('Use `/coven disable` to disable Coven Notifications.')
                else:
                    await self.bot.say('Use `/coven enable` to enable Coven Notifications.')
        else:
            await self.bot.say('<@' + authorid + '> **||** This command is only usable in <#288455332173316106> or '
                                                 '<#288463362357067777>.')
            return
Exemplo n.º 2
0
async def access(ctx):
    if ctx.message.channel.id == "439139494684262400":
        member = ctx.message.author
        await bot.delete_message(ctx.message)
        if discord.Role(server=discord.Server(id=server),
                        id="439138951916290059") not in member.roles:
            await bot.add_roles(
                member,
                discord.Role(server=discord.Server(id=server),
                             id=439138951916290059))
            await bot.send_message(
                member,
                "You have recieved access! The IP for the server is starquest.spacebeaverstudios.com. Click this link to see more info about StarQuest and how to get the resource pack! <https://discordapp.com/channels/160246330701250560/351432162232500225?jump=394914296796151808>"
            )
Exemplo n.º 3
0
    async def final(self, ctx, *, gamemode):
        """Notify a game is starting"""

        toscd = discord.Server(id='288455332173316106')
        optinrole = discord.Role(id='379748801197637644',
                                 server='288455332173316106')

        if gamemode is None:
            gamemode = "Not defined"

        gamemode = str(gamemode)
        auth = str(ctx.message.author.id)

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Game Notifications",
                                 colour=discord.Colour(0x880999),
                                 mentionable=True)

        await self.bot.say(
            """<@&379748801197637644> **||** This is the final call for a game of **"""
            + gamemode + """** is starting.
The game will start shortly.

Use `/joingame [Town of Salem IGN]` or `/jg [ToS IGN]` to join. You will shortly after get a party invite."""
        )

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Game Notifications",
                                 colour=discord.Colour(0x880999),
                                 mentionable=False)
Exemplo n.º 4
0
    async def host(self, ctx, *, gamemode):
        """Notify a game is starting"""

        channel = ctx.message.channel
        channelid = str(channel.id)
        authorid = str(ctx.message.author.id)

        toscd = discord.Server(id='288455332173316106')
        optinrole = discord.Role(id='358655924342095874', server='288455332173316106')

        if gamemode is None:
            gamemode = "Not defined"

        gamemode = str(gamemode)
        auth = str(ctx.message.author.id)

        await self.bot.edit_role(toscd, optinrole, name="Coven Notifications",
                                 colour=discord.Colour(0x550a94), mentionable=True)

        await self.bot.say("""<@&358655924342095874> **||** A new game of **""" + gamemode + """** is starting.


Use `/joingame [Town of Salem IGN]` or `/jg [ToS IGN]` to join. You will shortly after get a party invite.""")

        await self.bot.edit_role(toscd, optinrole, name="Coven Notifications",
                                 colour=discord.Colour(0x550a94), mentionable=False)

        await self.bot.send_message(self.bot.get_channel('407003125128495104'), "Names for the game of **"
                                    + str(gamemode) + "** are being posted below.")
Exemplo n.º 5
0
    async def enable(self, ctx):
        channel = ctx.message.channel
        channelid = str(channel.id)
        authorid = str(ctx.message.author.id)

        if channelid in [
                '288463362357067777', '288455332173316106',
                '296069608216068098'
        ]:
            pass
        else:
            await self.bot.say(
                "<@" + str(ctx.message.author.id) +
                "> **||** This command is only usable in "
                "<#288455332173316106>, <#288463362357067777> or "
                "<#358331904233046016>.")
            return

        user = ctx.message.author
        optinrole = discord.Role(id='358655924342095874',
                                 server='288455332173316106')

        await self.bot.add_roles(user, optinrole)
        await self.bot.say(
            'You will now **recieve** coven game notifications. Use `/coven disable` to *disable* them.'
        )
Exemplo n.º 6
0
    async def gamemodes(self, ctx):
        """Vote for today's gamemodes"""

        toscd = discord.Server(id='288455332173316106')
        emoteLib = discord.Server(id='401122122400923648')
        optinrole = discord.Role(id='358655924342095874',
                                 server='288455332173316106')

        auth = str(ctx.message.author.id)

        animpartyblob1 = discord.Emoji(name='animpartyblob1', server=emoteLib)

        classic = discord.Emoji(id='406242997852700672', server=toscd)
        rp = discord.Emoji(id='406242997903163392', server=toscd)
        custom = discord.Emoji(id='406242997584396299', server=toscd)
        eve = discord.Emoji(id='406242997492252674', server=toscd)
        rm = discord.Emoji(id='406242997727133697', server=toscd)
        aa = discord.Emoji(id='406242998205153298', server=toscd)
        mr = discord.Emoji(id='406242998083649546', server=toscd)

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Coven Notifications",
                                 colour=discord.Colour(0x550a94),
                                 mentionable=True)

        msg = await self.bot.say(
            """<a:animpartyblob1:401122373236948993> <a:animpartyblob2:401122373367234570> <a:animpartyblob3:401122373396463616> <a:animpartyblob4:401122373262376971> <a:animpartyblob5:401122373425823744> <a:animpartyblob6:401122373614567434> <a:animpartyblob7:401122373698322432> <a:animpartyblob8:401122373270503427> <a:animpartyblob9:401122373434343431>
<@&358655924342095874> **||** We're voting for today's coven gamemodes! React to a gamemode to react.
You may choose more than 1.

**You may choose from these options:**
<:CovenNormalClassic:406242997852700672> - Classic.
<:CovenRankedPractice:406242997903163392> - Ranked Practice.
<:CovenCustomCustom:406242997584396299> - Custom.
<:CovenEvilsVEvils:406242997492252674> - Evils v Evils.
<:CovenAllAny:406242997727133697> - All Any.
<:CovenMafiaReturns:406242998083649546> - Mafia Returns
<:CovenRotating:406242998205153298> - Rotating Gamemode (VIP or Lovers.)
""")

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Coven Notifications",
                                 colour=discord.Colour(0x550a94),
                                 mentionable=False)

        await self.bot.add_reaction(msg, classic)
        await self.bot.add_reaction(msg, rp)
        await self.bot.add_reaction(msg, custom)
        await self.bot.add_reaction(msg, eve)
        await self.bot.add_reaction(msg, rm)
        await self.bot.add_reaction(msg, mr)
        await self.bot.add_reaction(msg, aa)

        def save(self):
            dataIO.save_json("data/hostdata/data.json", self.db)
Exemplo n.º 7
0
    async def create_role(self, guild_id, *, reason=None, **fields):
        locs = self._get_higher_locs(1)
        guild = locs.get("self", None)

        data = facts.make_role_dict(**fields)
        role = discord.Role(state=get_state(), data=data, guild=guild)
        await _dispatch_event("create_role", guild, role, reason=reason)

        return facts.dict_from_role(role)
Exemplo n.º 8
0
async def unmute(ctx, member: discord.Member):
    try:
        if ctx.message.channel.permissions_for(
                ctx.message.author).manage_messages:
            await bot.remove_roles(
                member, discord.Role(server=discord.Server(id=server),
                                     id=role))
            await bot.say("{0.name} has been ungulagged".format(member))
    except Exception as e:
        await bot.say(e)
Exemplo n.º 9
0
    async def create_role(self, guild_id, *, reason=None, **fields):
        locs = self._get_higher_locs(1)
        guild = locs.get("self", None)

        data = facts.make_role_dict(**fields)
        # TODO: Replace with a backend make_role, to match other things
        role = discord.Role(state=get_state(), data=data, guild=guild)
        await callbacks.dispatch_event("create_role", guild, role, reason=reason)

        return facts.dict_from_role(role)
Exemplo n.º 10
0
 async def myRoleText(self, message_object, args):
     if args != "":
         print("\t[Debug-]{0}".format(args))
         if self.roleDB.contains((Query().user == message_object.author.id) & (Query().server == message_object.server.id)):
             role = discord.Role(
                 server=message_object.server.id, 
                 id=self.roleDB.search((Query().user == message_object.author.id) & (Query().server == message_object.server.id))[0]['role'] )
             print("\t[Debug-]{0}".format("Modifying Role"))
             await self.pm.client.edit_role(message_object.server, role, 
                 name=args)
     else:
         await self.pm.client.send_message(message_object.channel, ':information_source:`Usage: ~mytext [text]`'.format(message_object.author.mention))
Exemplo n.º 11
0
 def _handle_option_role(
     self, data: dict, option: ResponseOption, resolved: Dict[str, Dict[str, dict]]
 ):
     role_id = int(data["value"])
     resolved_role = resolved["roles"][data["value"]]
     if self.guild_id:
         if role := self.guild.get_role(role_id):
             pass
         else:
             role = discord.Role(guild=self.guild, data=resolved_role, state=self)
             self.guild._add_role(role)
         option.set_value(role)
Exemplo n.º 12
0
    async def togglehost(self, ctx):
        author = ctx.message.author
        localRoleAdmin = discord.Role(id='414196360321957888',
                                      server='288455332173316106')
        localRoleSeniorMod = discord.Role(id='414189641890267157',
                                          server='288455332173316106')
        localRoleMod = discord.Role(id='414196360321957888',
                                    server='288455332173316106')
        administrator = discord.Role(id='288457272663867392',
                                     server='288455332173316106')
        seniorModerator = discord.Role(id='288464565791096838',
                                       server='288455332173316106')
        moderator = discord.Role(id='288682024515141634',
                                 server='288455332173316106')

        # Checks to find which role in the hierarchy they need

        if moderator in author.roles:  #  If they are a Moderator...
            localRole = localRoleMod
        elif seniorModerator in author.roles:  #  If they are a Senior Mod...
            localRole = localRoleSeniorMod
        elif administrator in author.roles:
            localRole = localRoleAdmin
        else:
            return

        if localRole in author.roles:  #  If the hosting role is in the author
            await self.bot.remove_roles(author, localRole)  # Remove the role
            await self.bot.say('Successfully removed the Hosting role.')
        else:  # If the hosting role not in the author
            await self.bot.add_roles(author, localRole)  # Add the role
            await self.bot.say('Successfully added the Hosting role.')
Exemplo n.º 13
0
async def mute(ctx, member: discord.Member):
    try:
        if ctx.message.channel.permissions_for(
                ctx.message.author).manage_messages:
            await bot.add_roles(
                member, discord.Role(server=discord.Server(id=server),
                                     id=role))
            await bot.send_file(
                ctx.message.channel,
                fp="gulag.png",
                content='{0.name} has been gulagged'.format(member))
    except Exception as e:
        await bot.say(e)
Exemplo n.º 14
0
    async def gamemodes(self, ctx):
        """Vote for today's gamemodes"""

        toscd = discord.Server(id='288455332173316106')
        optinrole = discord.Role(id='379748801197637644',
                                 server='288455332173316106')

        classic = discord.Emoji(id='386748316894887938', server=toscd)
        rp = discord.Emoji(id='386742079252070401', server=toscd)
        custom = discord.Emoji(id='386742078975115265', server=toscd)
        eve = discord.Emoji(id='386742078912069633', server=toscd)
        rm = discord.Emoji(id='386748316886499328', server=toscd)
        aa = discord.Emoji(id='386742078421467159', server=toscd)
        rain = discord.Emoji(id='386742078845222937', server=toscd)
        vigil = discord.Emoji(id='386742078471667714', server=toscd)

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Game Notifications",
                                 colour=discord.Colour(0x880999),
                                 mentionable=True)

        msg = await self.bot.say(
            """<a:animpartyblob1:401122373236948993> <a:animpartyblob2:401122373367234570> <a:animpartyblob3:401122373396463616> <a:animpartyblob4:401122373262376971> <a:animpartyblob5:401122373425823744> <a:animpartyblob6:401122373614567434> <a:animpartyblob7:401122373698322432> <a:animpartyblob8:401122373270503427> <a:animpartyblob9:401122373434343431>
<@&379748801197637644> **||** We're voting for today's gamemodes! React to a gamemode to react.
You may choose more than 1.

**You may choose from these options:**
<:NormalClassic:386748316894887938> - Classic.
<:NormalRankedPractice:386742079252070401> - Ranked Practice.
<:CustomCustom:386742078975115265> - Custom.
<:CustomEvilsvEvils:386742078912069633> - Evils v Evils.
<:CustomRapidMode:386748316886499328> - Rapid Mode.
<:ChaosAllAny:386742078421467159> - All Any.
<:ChaosRainbow:386742078845222937>- Rainbow.
<:ChaosVigilantics:386742078471667714> - Vigilantics.""")

        await self.bot.edit_role(toscd,
                                 optinrole,
                                 name="Game Notifications",
                                 colour=discord.Colour(0x880999),
                                 mentionable=False)

        await self.bot.add_reaction(msg, classic)
        await self.bot.add_reaction(msg, rp)
        await self.bot.add_reaction(msg, custom)
        await self.bot.add_reaction(msg, eve)
        await self.bot.add_reaction(msg, rm)
        await self.bot.add_reaction(msg, aa)
        await self.bot.add_reaction(msg, rain)
        await self.bot.add_reaction(msg, vigil)
Exemplo n.º 15
0
def fake_guild_role(guild: discord.Guild) -> discord.Role:
    fake_role = discord.Role(guild=guild,
                             state=None,
                             data={
                                 'id': dpyfactory.make_id(),
                                 'name': fake_custom_emoji_name_str(),
                                 'mentionable': True,
                                 'hoist': True,
                                 'managed': False,
                                 'colour': random.randint(0, 16777215),
                                 'permissions': 8
                             })
    guild._add_role(fake_role)
    return fake_role
Exemplo n.º 16
0
async def science(ctx):
    if ctx.message.server.id == "160246330701250560":
        member = ctx.message.author
        if discord.Role(server=discord.Server(id=server),
                        id="439700931932585987") not in member.roles:
            await bot.add_roles(
                member,
                discord.Role(server=discord.Server(id=server),
                             id=439700931932585987))
            msg = await bot.send_message(
                ctx.message.channel, "You have recieved the Scientist role")
            await asyncio.sleep(10)
            await bot.delete_message(ctx.message)
            await bot.delete_message(msg)

        else:
            await bot.remove_roles(
                member,
                discord.Role(server=discord.Server(id=server),
                             id="439700931932585987"))
            msg = await bot.say("You no longer have the Scientist role")
            await asyncio.sleep(10)
            await bot.delete_message(ctx.message)
            await bot.delete_message(msg)
Exemplo n.º 17
0
    def __init__(self, *, data, guild, state):
        self.members: Dict[int, discord.Member] = {}
        self.users: Dict[int, discord.User] = {}
        self.roles: Dict[int, discord.Role] = {}
        self.channels: Dict[int, discord.abc.GuildChannel] = {}
        self.messages: Dict[int, discord.Message] = {}

        users = data.get("users", {})
        members = data.get("members", {})
        roles = data.get("roles", {})
        channels = data.get("channels", {})
        messages = data.get("messages", {})

        for ID, data in users.items():
            user_id = int(ID)
            if ID in members:
                self.members[user_id] = discord.Member(
                    data={
                        **members[ID], "user": data
                    },
                    guild=guild,
                    state=state  # type: ignore
                )
            else:
                self.users[user_id] = discord.User(state=state, data=data)

        for ID, data in roles.items():
            self.roles[int(ID)] = discord.Role(guild=guild,
                                               state=state,
                                               data=data)

        for ID, data in channels.items():
            data["position"] = 0
            factory, ch_type = discord.channel._channel_factory(data["type"])
            if factory:
                self.channels[int(ID)] = factory(guild=guild,
                                                 data=data,
                                                 state=state)

        for ID, data in messages.items():
            channel_id = int(data["channel_id"])
            channel = guild.get_channel(channel_id) if guild else None
            if channel is None:
                channel = state.get_channel(channel_id)
            self.messages[int(ID)] = discord.Message(state=state,
                                                     channel=channel,
                                                     data=data)
Exemplo n.º 18
0
    async def myRole(self, message_object, args):
        if args != "":
            color = args.split(" ")[0]
            try:
                roleText = args[len(color):]
            except:
                roleText = message_object.author.name + "'s Color"

            if re.search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', color):
                print("\t[Debug-]{0}".format(args))
                if self.roleDB.contains((Query().user == message_object.author.id) & (Query().server == message_object.server.id)):
                    role = discord.Role(
                        server=message_object.server.id, 
                        id=self.roleDB.search((Query().user == message_object.author.id) & (Query().server == message_object.server.id))[0]['role'] )
                    
                    print("\t[Debug-]{0}".format("Modifying Role"))
                    await self.pm.client.edit_role(message_object.server, role, 
                        name=roleText, 
                        color=discord.Colour(int(color[1:], 16)))
                else:
                    print("\t[Debug-]{0}".format("Creating Role"))
                    newrole = await self.pm.client.create_role(message_object.server)
                    newrole.name = message_object.author.name + "'s Color"
                    newrole.colour = discord.Colour((int(color[1:], 16)))
                    self.roleDB.insert({'user' : message_object.author.id,
                    'role' : newrole.id,
                    'server' : message_object.server.id})
                    print("\t[Debug-]{0}".format("Setting Role to User"))
                    await self.pm.client.add_roles(message_object.author, newrole)
                    print("\t[Debug-]{0}".format("Editing Role Properties"))
                    await self.pm.client.edit_role(message_object.server, newrole, 
                        name=message_object.author.name + "'s Color", 
                        color=discord.Colour(int(color[1:], 16)))
                    print("\t[Debug-]{0}".format("Setting Role Position"))
                    await self.pm.client.move_role(message_object.server, newrole, self.roleposition) 
                    print("\t[Debug-]{0}".format("Done!"))
                await self.pm.client.send_message(message_object.channel, ':information_source:`Your custom role has been changed to {0}!`'.format(args))
            else:
                await self.pm.client.send_message(message_object.channel, ':information_source:`{0} is an invalid Hex colour!`'.format(args))

        else:
            await self.pm.client.send_message(message_object.channel, ':information_source:`Usage: ~myrole [#color] [text?]`'.format(message_object.author.mention))
Exemplo n.º 19
0
def extract_counselors(client: discord.client):
    guild = client.get_guild(ID)
    eo = discord.Role(data={
        'id': 718625920805765171,
        'name': "@EstudianteOrientador"
    },
                      guild=guild,
                      state=None)
    for member in guild.members:
        for role in member.roles:
            if member is not None and eo in member.roles:
                if 'INEL' in role.name:
                    log.debug(f"[INEL] Role Found for {member.nick}")
                    inel_counselors.add(member)
                if 'ICOM' in role.name:
                    log.debug(f"[ICOM] Role Found for {member.nick}")
                    icom_counselors.add(member)
                if 'INSO/CIIC' in role.name:
                    log.debug(f"[INSO/CIIC] Role Found for {member.nick}")
                    cse_counselors.add(member)
Exemplo n.º 20
0
    async def task_VerifyUsers(self, client):
        await client.wait_until_ready()

        # Server
        sv = list(client.servers)[0]

        # Welcome channel
        welcome_ch = discord.Object(id=self.getConfig('welcome_ch'))
        mods_ch = discord.Object(id=self.getConfig('mods_ch'))

        for i, uid in enumerate(self.data['ok']):
            user = sv.get_member(uid)

            # Role used for verification
            verified = discord.Role(server=sv,
                                    id=self.getConfig('verified_role'))

            # Verify user
            await client.replace_roles(user, verified)

            # And greet them
            await client.send_message(welcome_ch,
                                      self.getConfig('welcome_msg')
                                      .format(uid=user.id,
                                              number=sv.member_count))
            await client.send_message(user, self.getConfig('welcome_pm'))

            self.data['ok'][i] = ''

        for i, uid in enumerate(self.data['bad']):
            user = sv.get_member(uid)
            await client.send_message(mods_ch,
                                      'User <@{}> requires verification.'
                                      .format(user.id))

            self.data['bad'][i] = ''

        # Clean the OK and BAD lists
        self.data['ok'] = [x for x in self.data['ok'] if x != '']
        self.data['bad'] = [x for x in self.data['bad'] if x != '']
Exemplo n.º 21
0
async def create_random_roles(guild: discord.Guild) -> List[discord.Role]:
    names = (
        "Red",
        "Green",
        "Blue",
        "Orange",
        "Yellow",
        "Purple",
        "Owner",
        "Member",
        "A Random Role",
        "I don't have ideas anymore",
    )
    roles = []

    for i in range(len(names)):
        data = {"id": i, "name": names[i]}
        role = discord.Role(guild=guild, state=State(), data=data)
        roles.append(role)
        await dpytest.create_role_callback(guild, role)

    return roles
Exemplo n.º 22
0
    async def on_member_join(self, client, user):
        # Server
        sv = list(client.servers)[0]

        # Role used for verification
        unverified = discord.Role(server=sv,
                                  id=self.getConfig('unverified_role'))

        # Set them to "Unverified" as soon as they join
        await client.add_roles(user, unverified)

        # Generate their PIN-code
        pin = ''.join([str(randint(0, 9)) for _ in range(6)])
        while pin in self.data['codes'].values():
            pin = ''.join([str(randint(0, 9)) for _ in range(6)])

        self.data['codes'][str(user.id)] = pin

        self.log('[pin] {} ({}): {}'.format(user.name, user.id, pin))

        # Send the help message
        auth_msg = (
            'Welcome to the Pixel Art server, <@{id}>!\n\n'
            'Due to recent ban circumvention issues caused by malicious'
            ' users, we are sorry to inform you that we now require'
            ' newcomers to confirm their account via the following'
            ' procedure:\n\n'
            '**1.** Visit the following link:'
            ' http://pixelverify.tk:8080/?uid={id}\n'
            '**2.** Enter the following generated PIN-code: ***{code}***\n'
            '**3.** Done! :smiley:'
        )

        await client.send_message(user, auth_msg.format(
            id=user.id,
            code=pin
        ))
Exemplo n.º 23
0
import logging
import json
from collections import Counter, OrderedDict
import discord
from discord.ext import commands
from   discord import errors
import subprocess
import traceback

# Load settings.
settingsPath = "./settings.json"
with open(settingsPath) as f:
    settings = json.load(f)

# Information for the muted role.
Muted = discord.Role(id=settings['muted'],server=settings['server'])

class tempMute:
    def __init__(self, bot):
        self.bot = bot

    @commands.command(pass_context=True)
    async def tempmute(self, ctx, member:discord.Member, mutedTime, *, reason):
        
        # Multiplies the received muted time by 60 and converts it into an integer.
        totalMutedTime = int(mutedTime)*60
        
        # Process the command if the user is inside the team role.
        if "team" in [y.name.lower() for y in ctx.message.author.roles] and totalMutedTime <= 86400 and not "muted" in [y.name.lower() for y in member.roles] and member.id != settings['botid']:
            
            # Adds the Muted role to the targeted user.
Exemplo n.º 24
0
    "preferred_locale": "UTC",
    "owner_id": 1,
    "afk_channel_id": 464033278631084042
}

guild_instance = discord.Guild(data=guild_data, state=MagicMock())

member_data = {"user": "******", "roles": [1]}
state_mock = MagicMock()
member_instance = discord.Member(data=member_data,
                                 guild=guild_instance,
                                 state=state_mock)

role_data = {"name": "role", "id": 1}
role_instance = discord.Role(guild=guild_instance,
                             state=MagicMock(),
                             data=role_data)

context_instance = Context(message=MagicMock(), prefix=MagicMock())

message_data = {
    "id": 1,
    "webhook_id": 431341013479718912,
    "attachments": [],
    "embeds": [],
    "application": "Python Discord",
    "activity": "mocking",
    "channel": MagicMock(),
    "edited_timestamp": "2019-10-14T15:33:48+00:00",
    "type": "message",
    "pinned": False,
Exemplo n.º 25
0
    def __init__(self, shell=False):
        if not shell:
            discord.Client.__init__(self)
            # Timezone
            self.timezone = Zone.Zone(10, False, 'AEST')
            self.localtime = pytz.timezone('Australia/Sydney')

            self.five_alert = False
            self.one_alert = False
            self.alert_times = [[1, 3, 5, 7, 9, 19, 21, 23],
                                [0, 2, 4, 6, 8, 18, 20, 22]]
            self.alert_clear = []

            self.todayTZ = self.localtime.localize(datetime.today())

            self.kritiasChannel = discord.Channel(
                id='386135531483955220',
                server=discord.Server(id='260325692040937472'))
            self.kritiasWatch = discord.Role(
                id='386135324918808576',
                server=discord.Server(id='260325692040937472'))

            # Logger
            self.logger = None

            # JSON Properties
            self.json_data = None
            self.get_json_properties()
            self.commands = []
            self.sub_commands = []
            self.command_level = {}
            self.load_commands()
            for x in self.json_data['Commands'].keys():
                self.sub_command_crawler(x)

            # Spreadsheet Accessor
            self.spreadsheet_accessor = SpreadsheetAccessor.SpreadsheetAccessor(
                self.logger)
            self.locals = {}

            # Reddit API

            redditAPI = None
            self.subreddits = []

            self.load_subreddit_pages()
            self.pool = {}

            self.reddit = praw.Reddit(
                client_id=os.environ['rapi_client_id'],
                client_secret=os.environ['rapi_client_secret'],
                username=os.environ['rapi_username'],
                password=os.environ['rapi_password'],
                user_agent=os.environ['rapi_user_agent'])

            # Commands and command handlers
            self.command_queue = Queue()

            for x in range(4):
                t = threading.Thread(target=self.message_worker)
                t.daemon = True
                t.start()
            self.local_data_queue = Queue()
            # Local data creator handlers
            for x in range(4):
                t = threading.Thread(target=self.local_worker)
                t.daemon = True
                t.start()

            self.prefix = self.json_data['Prefix']
            self.load_to_local()
            self.loop.create_task(self.kritias_alert())

            self.loop.create_task(self.spreadsheet_connection_refresher())
            #self.loop.create_task(self.daily_puzzle())
            for x, entry in enumerate(self.subreddits):
                self.loop.create_task(self.submission_puller(entry))
Exemplo n.º 26
0
class Roles:
    alpaca = discord.Role(id="474224730245955584", server=Servers.FGL)
Exemplo n.º 27
0
import requests

# Discord bot client
token = ""  # Discord bot token goes here
clevertoken = ""  # Cleverbot token goes here
cl = discord.Client()
u = {}
p = {}
cs = {}
s = 0

# Constants
mat1 = discord.User(id="224862746964000768")
server = discord.Server(id="369571978019078144")
roles = [
    discord.Role(id="389922207419072512", server=server),
    discord.Role(id="385788047146483714", server=server),
    discord.Role(id="389928722322554881", server=server)
]
rolenames = ["Launchpadder", "Launchpad Creator", "Music Producer"]
r = [
    '1\N{COMBINING ENCLOSING KEYCAP}', '2\N{COMBINING ENCLOSING KEYCAP}',
    '3\N{COMBINING ENCLOSING KEYCAP}'
]
y = ['✅', '🚫']
prefix = "!"

# Strings
current = 'Your current roles are:'
apply = 'Which role would you like to apply for?'
submitted = ['Your application for', 'has been submitted!']
Exemplo n.º 28
0
async def on_message(message):
    if message.content.upper().startswith(command("HELP", message)):
        msg = "Hello, {0.author.mention}! I am ***TBD***. I am an unfinished bot thereby having no working commands.".format(
            message)
        await message.channel.send(msg)

    elif message.content.upper().startswith(command('RELAX', message)):
        msg = eyelist[randint(0, eyeCount)]
        await message.channel.send(msg)

    elif message.content.upper().startswith(command("HUG", message)):
        msg = "{0.author.mention} hugs {0.mentions[0].mention}".format(message)
        await message.channel.send(msg)
        msg = huglist[randint(0, hugCount)]
        await message.channel.send(msg)
        await message.delete()

    elif message.content.upper().startswith(command('INSULT', message)):
        msg = "{0.author.mention} says to {0.mentions[0].mention} ".format(
            message) + insult1list[randint(
                0, insult1Count)] + insult2list[randint(
                    0, insult2Count)] + insult3list[randint(0, insult3Count)]
        await message.channel.send(msg)
        await message.delete()

    elif message.content.upper().startswith(command("NO U", message)):
        msg = "{0.mentions[0].mention} ".format(message) + gaylist[randint(
            0, gayCount)]
        await message.channel.send(msg)
        await message.delete()

    elif message.content.upper().startswith(command("XBOX", message)):
        role = discord.Role(xbox)
        user = message.author
        await user.add_roles(role)

    elif message.content.upper().startswith(command('PC', message)):
        await client.add_role(message.author, pc)
        return await message.channel.send(
            "The role @PC has been given to {0.author.mention}".format(message)
        )

    elif message.content.upper().startswith(command("PLAYSTATION", message)):
        await client.add_role(message.author, playstation)
        return await message.channel.send(
            "The role @playstation has been given to {0.author.mention}".
            format(message))
    '''
    admin commands
    '''
    if message.content.upper().startswith(command('WARN', message)):
        if message.channel.permissions_for(
                message.author).administrator == True:
            msg = "{0.mentions[0].mention}, you have been warned by {0.author.mention}. Too many warning will result in a ban".format(
                message)
            await message.channel.send(msg)
        elif message.channel.permissions_for(
                message.author).administrator == False:
            msg = "Sorry {0.author.mention}. You do not have permission to use this command. DM an admin to report this player.".format(
                message)
            await message.channel.send(msg)

    async def kick(ctx, userName: discord.User):
        if message.content.upper().startswith(command("KICK", message)):
            if message.channel.permissions_for(
                    message.author).administrator == True:
                await client.kick(userName)
                msg = "{0.mentions[0].mention} has been kicked.".format(
                    message)
                await message.channel.send(msg)
            elif message.channel.permissions_for(
                    message.author).administrator == False:
                msg = "Sorry {0.author.mention}. You do not have permission to use this command. DM an admin to report this player.".format(
                    message)
                await message.channel.send(msg)
Exemplo n.º 29
0
    def __init__(self,
                 roles: Optional[Iterable[MockRole]] = None,
                 **kwargs) -> None:
        default_kwargs = {'id': next(self.discord_id), 'members': []}
        super().__init__(**collections.ChainMap(kwargs, default_kwargs))

        self.roles = [MockRole(name="@everyone", position=1, id=0)]
        if roles:
            self.roles.extend(roles)


# Create a Role instance to get a realistic Mock of `discord.Role`
role_data = {'name': 'role', 'id': 1}
role_instance = discord.Role(guild=guild_instance,
                             state=unittest.mock.MagicMock(),
                             data=role_data)


class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin,
               HashableMixin):
    """
    A Mock subclass to mock `discord.Role` objects.

    Instances of this class will follow the specifications of `discord.Role` instances. For more
    information, see the `MockGuild` docstring.
    """
    spec_set = role_instance

    def __init__(self, **kwargs) -> None:
        default_kwargs = {
Exemplo n.º 30
0
    def __init__(self, roles: Optional[Iterable['MockRole']] = None, **kwargs) -> None:
        default_kwargs = {'id': next(self.discord_id), 'members': []}
        super().__init__(**collections.ChainMap(kwargs, default_kwargs))

        self.roles = [MockRole(name="@everyone", position=1, id=0)]
        if roles:
            self.roles.extend(roles)

    def get_member(self, user_id: int) -> discord.Member:
        return discord.utils.get(self.members, id=user_id)


# Create a Role instance to get a realistic Mock of `discord.Role`
role_data = {'name': 'role', 'id': 1}
role_instance = discord.Role(guild=guild_instance, state=unittest.mock.MagicMock(), data=role_data)


class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin):
    """
    A Mock subclass to mock `discord.Role` objects.
    Instances of this class will follow the specifications of `discord.Role` instances. For more
    information, see the `MockGuild` docstring.
    """
    spec_set = role_instance

    def __init__(self, **kwargs) -> None:
        default_kwargs = {
            'id': next(self.discord_id),
            'name': 'role',
            'position': 1,