2017-05-04 07:16:49 +02:00
|
|
|
from titanembeds import Titan
|
2020-02-18 03:00:19 +01:00
|
|
|
from config import config
|
|
|
|
|
|
|
|
import argparse
|
2017-05-04 07:16:49 +02:00
|
|
|
import gc
|
2020-02-18 03:00:19 +01:00
|
|
|
import requests
|
|
|
|
|
|
|
|
def print_shards():
|
|
|
|
token = config["bot-token"]
|
|
|
|
url = "https://discordapp.com/api/v6/gateway/bot"
|
|
|
|
headers = {"Authorization": "Bot {}".format(token)}
|
|
|
|
r = requests.get(url, headers=headers)
|
|
|
|
if r.status_code >= 200 and r.status_code < 300:
|
|
|
|
print("Suggested number of shards: {}".format(r.json().get("shards", 0)))
|
|
|
|
else:
|
2020-02-18 03:10:24 +01:00
|
|
|
print("Status Code: {}".format(r.status_code))
|
2020-02-18 03:00:19 +01:00
|
|
|
print(r.text)
|
2017-05-04 05:22:27 +02:00
|
|
|
|
2017-05-04 07:16:49 +02:00
|
|
|
def main():
|
2020-02-18 03:00:19 +01:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description="Embed Discord like a True Titan (Discord Bot portion)"
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-sid",
|
|
|
|
"--shard_id",
|
|
|
|
help="ID of the shard",
|
|
|
|
type=int,
|
|
|
|
default=None
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-sc",
|
|
|
|
"--shard_count",
|
|
|
|
help="Number of total shards",
|
|
|
|
type=int,
|
|
|
|
default=None
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"-s",
|
|
|
|
"--shards",
|
|
|
|
help="Prints the reccomended number of shards to spawn",
|
|
|
|
action="store_true"
|
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.shards:
|
|
|
|
print_shards()
|
|
|
|
return
|
|
|
|
|
2017-05-04 07:16:49 +02:00
|
|
|
print("Starting...")
|
2020-02-18 03:00:19 +01:00
|
|
|
te = Titan(
|
|
|
|
shard_ids = [args.shard_id] if args.shard_id is not None else None,
|
|
|
|
shard_count = args.shard_count
|
|
|
|
)
|
2017-05-04 07:16:49 +02:00
|
|
|
te.run()
|
|
|
|
gc.collect()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|