Exemplo n.º 1
0
    def test_start_no_shardcount_no_id(self):
        bot = Client(0, token=env["BOT_TOKEN"])

        @bot.listen("READY")
        async def on_ready(data, shard):
            bot.exit_event.set()

        bot.run()
Exemplo n.º 2
0
def test_require_shard_count_shard_ids():
    from speedcord import Client
    try:
        Client(0, shard_ids=[0, 2, 4])
    except TypeError:
        pass
    else:
        raise Exception("Did not verify if shard_count was passed.")
Exemplo n.º 3
0
"""
Created by Epic at 9/17/20
"""
from speedcord import Client, http
from speedutils import typing
from os import environ as env
from pymongo import MongoClient
from checks.user import duplicated_pokemon_id_one_user

bot = Client(512, token=env["TOKEN"])
db_client = MongoClient(env["MONGO_URI"])
db = db_client.pokebot
users_table = db.users
pokemon_table = db.users_pokemoms

banned_users = []
user_checks = [duplicated_pokemon_id_one_user]

api = http.HttpClient("", baseuri="http://pokebotapi/api")
api.default_headers["Authorization"] = env["API_AUTH"]  # TODO: Change format to "Admin <token>"


@bot.listen("MESSAGE_CREATE")
async def on_message(data, shard):
    args = data["content"].lower().split(" ")
    if args[0] == "wtf!status":
        route = typing.send_message(data["channel_id"])
        await bot.http.request(route, json={"content": f"Total banned users: {len(banned_users)}"})
    elif args[0] == "wtf!ban":
        # TODO: Implement this
        if env["MOD_ROLE_ID"] not in data["member"]["roles"]:
Exemplo n.º 4
0
"""
Created by Epic at 9/24/20
"""
from speedcord import Client
from os import environ as env
import commands
import commandhandler

bot = Client(640)
bot.command_handler = commandhandler.CommandHandler(bot, env["PREFIX"])

# Register commands
bot.command_handler.command_handlers["help"] = commands.help_command


@bot.listen("MESSAGE_CREATE")
async def on_message(data, shard):
    print("Got message")
    await bot.command_handler.handle_message(data)


bot.token = env["TOKEN"]

bot.run()
Exemplo n.º 5
0
from speedcord import Client
from speedcord.http import Route
from os import environ as env
from random import choice

client = Client(2)
client.current_shard_count = 1  # Hacky fix until its fixed
client.token = env["TOKEN"]

roles = env["ROLES"].split(";")


@client.listen("GUILD_MEMBER_ADD")
async def on_member_join(data, _):
    user_id = data["user"]["id"]
    guild_id = data["guild_id"]
    route = Route("PUT",
                  "/guilds/{guild_id}/members/{user_id}/roles/{role_id}",
                  guild_id=guild_id,
                  user_id=user_id,
                  role_id=choice(roles))
    await client.http.request(route)


client.run()
Exemplo n.º 6
0
"""
Created by Epic at 10/15/20
"""
from speedcord import Client
from speedcord.http import Route
from speedcord.ext.typing.context import MessageContext
from os import environ as env

client = Client(512)
client.token = env["token"]


@client.listen("MESSAGE_CREATE")
async def on_message(data, shard):
    if len(data.get("sticker_items", [])) != 0:
        r = Route("DELETE",
                  "/channels/{channel_id}/messages/{message_id}",
                  channel_id=data["channel_id"],
                  message_id=data["id"])
        await client.http.request(r)
        r = Route("POST",
                  "/channels/{channel_id}/messages",
                  channel_id=data["channel_id"])
        await client.http.request(
            r,
            json={
                "content":
                f"Yoo you dumbass stop using the sticker or I'll hack you <@{data['author']['id']}>"
            })

Exemplo n.º 7
0
"""
Created by Epic at 9/5/20
"""
from speedcord import Client
from speedian.command_handler import CommandHandler
from logging import basicConfig, DEBUG
from os import environ as env
from elasticsearch import AsyncElasticsearch

basicConfig(level=DEBUG)

client = Client(1536, env["TOKEN"])
client.elastic = AsyncElasticsearch(
    hosts=("localhost", "elastic")[bool(env.get("PROD_ENV"))])

commands = CommandHandler(client,
                          env["CLIENT_ID"],
                          guild_id=env.get("DEBUG_GUILD"))
commands.load_extension("discover")
commands.load_extension("manage")
commands.load_extension("utils")


async def setup():
    await client.elastic.indices.create("channels", ignore=400)


client.loop.create_task(setup())
client.run()