-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsellix.py
More file actions
84 lines (76 loc) · 2.33 KB
/
sellix.py
File metadata and controls
84 lines (76 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import discord
from discord import channel
from discord.client import Client
import dotenv
import requests
import json
import requests
import os
from requests.api import head
from requests.structures import CaseInsensitiveDict
from os.path import join, dirname
from dotenv import load_dotenv
from os import system
import datetime
from discord.ext import commands
prefix=os.getenv('PREFIX')
token = os.getenv('TOKEN')
secret_key = os.getenv('API_KEY')
bot = commands.Bot(command_prefix=prefix)
bot.remove_command("help")
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
@bot.event
async def on_ready():
print('-------')
print('Online')
print('-------')
@bot.event
async def on_command_error(ctx, error):
embed = discord.Embed(title="-_-", description="You are using that command wrong, please retry with the correct roles or arguments.")
embed.set_footer(text="-skeet")
await ctx.send(embed=embed)
print(error)
@bot.command()
async def list(ctx):
order = "https://dev.sellix.io/v1/orders"
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
print (secret_key)
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
head= 'Bearer '+secret_key
headers["Authorization"] = head
resp = requests.get(order, headers=headers)
output = resp.text
parsed = json.loads(output)
file="all.json"
o = open(file,"w")
o.write(json.dumps(parsed, indent=2))
#print (json.dumps(parsed, indent=2))
await ctx.send(file=discord.File(file))
@bot.command()
async def order(ctx,description):
order = "https://dev.sellix.io/v1/orders/" + description
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)
secret_key = os.getenv('API_KEY')
print (secret_key)
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
head= 'Bearer '+secret_key
headers["Authorization"] = head
resp = requests.get(order, headers=headers)
output = resp.text
parsed = json.loads(output)
file ="order " + description
o = open(file,"w")
o.write(json.dumps(parsed, indent=2))
print(description)
await ctx.send(file=discord.File(file))
@bot.command()
async def time(description,ctx)
now = datetime.datetime.now()
print(description)
await ctx.send(now)
bot.run(token)