fix: convert to lf

This commit is contained in:
Rushil Umaretiya 2022-02-20 12:02:21 -05:00
parent 44f54ad252
commit a3d25b22de
4 changed files with 418 additions and 418 deletions

View File

@ -1,3 +1,3 @@
DISCORD_TOKEN='' DISCORD_TOKEN=''
THRESHOLD=0.1 THRESHOLD=0.1
MENTION_ROLE=alert MENTION_ROLE=alert

304
.gitignore vendored
View File

@ -1,153 +1,153 @@
# disc bot # disc bot
.env .env
discord.log discord.log
#led / optimized / DLL files #led / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*$py.class *$py.class
secrets.py secrets.py
static_files static_files
.idea/ .idea/
.vscode/ .vscode/
/static /static
# C extensions # C extensions
*.so *.so
# Distribution / packaging # Distribution / packaging
.Python .Python
build/ build/
develop-eggs/ develop-eggs/
dist/ dist/
downloads/ downloads/
eggs/ eggs/
.eggs/ .eggs/
lib/ lib/
lib64/ lib64/
parts/ parts/
sdist/ sdist/
var/ var/
wheels/ wheels/
share/python-wheels/ share/python-wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
MANIFEST MANIFEST
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it. # before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest *.manifest
*.spec *.spec
# Installer logs # Installer logs
pip-log.txt pip-log.txt
pip-delete-this-directory.txt pip-delete-this-directory.txt
# Unit test / coverage reports # Unit test / coverage reports
htmlcov/ htmlcov/
.tox/ .tox/
.nox/ .nox/
.coverage .coverage
.coverage.* .coverage.*
.cache .cache
nosetests.xml nosetests.xml
coverage.xml coverage.xml
*.cover *.cover
*.py,cover *.py,cover
.hypothesis/ .hypothesis/
.pytest_cache/ .pytest_cache/
cover/ cover/
# Translations # Translations
*.mo *.mo
*.pot *.pot
# Django stuff: # Django stuff:
*.log *.log
local_settings.py local_settings.py
db.sqlite3 db.sqlite3
db.sqlite3-journal db.sqlite3-journal
# bruh windows # bruh windows
*:Zone.Identifier *:Zone.Identifier
# Flask stuff: # Flask stuff:
instance/ instance/
.webassets-cache .webassets-cache
# Scrapy stuff: # Scrapy stuff:
.scrapy .scrapy
# Sphinx documentation # Sphinx documentation
docs/_build/ docs/_build/
# PyBuilder # PyBuilder
.pybuilder/ .pybuilder/
target/ target/
# Jupyter Notebook # Jupyter Notebook
.ipynb_checkpoints .ipynb_checkpoints
# IPython # IPython
profile_default/ profile_default/
ipython_config.py ipython_config.py
# pyenv # pyenv
# For a library or package, you might want to ignore these files since the code is # For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in: # intended to run in multiple environments; otherwise, check them in:
# .python-version # .python-version
# pipenv # pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies # However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not # having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies. # install all needed dependencies.
#Pipfile.lock #Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow # PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/ __pypackages__/
# Celery stuff # Celery stuff
celerybeat-schedule celerybeat-schedule
celerybeat.pid celerybeat.pid
# SageMath parsed files # SageMath parsed files
*.sage.py *.sage.py
# Environments # Environments
.env .env
.venv .venv
env/ env/
venv/ venv/
ENV/ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
# Spyder project settings # Spyder project settings
.spyderproject .spyderproject
.spyproject .spyproject
# Rope project settings # Rope project settings
.ropeproject .ropeproject
# mkdocs documentation # mkdocs documentation
/site /site
# mypy # mypy
.mypy_cache/ .mypy_cache/
.dmypy.json .dmypy.json
dmypy.json dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# pytype static type analyzer # pytype static type analyzer
.pytype/ .pytype/
# Cython debug symbols # Cython debug symbols
cython_debug/ cython_debug/
#VSCODE #VSCODE
.vscode/* .vscode/*

42
LICENSE
View File

@ -1,21 +1,21 @@
MIT License MIT License
Copyright (c) 2022 Rushil Umaretiya Copyright (c) 2022 Rushil Umaretiya
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.

486
bot.py
View File

@ -1,243 +1,243 @@
import aiosqlite import aiosqlite
import discord import discord
import logging import logging
import requests import requests
import random import random
from datetime import datetime from datetime import datetime
from discord.ext import commands, tasks from discord.ext import commands, tasks
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
load_dotenv() load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN') TOKEN = os.getenv('DISCORD_TOKEN')
MENTION_ROLE = str(os.getenv('MENTION_ROLE')) MENTION_ROLE = str(os.getenv('MENTION_ROLE'))
THRESHOLD = float(os.getenv('THRESHOLD')) THRESHOLD = float(os.getenv('THRESHOLD'))
API_ENDPOINT = 'http://api-mainnet.magiceden.dev/v2/' API_ENDPOINT = 'http://api-mainnet.magiceden.dev/v2/'
NFT_LINKS = [ NFT_LINKS = [
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Brown.gif", "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Brown.gif",
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Orangutan.gif", "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Orangutan.gif",
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Green.gif", "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Green.gif",
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Blue.gif", "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Blue.gif",
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Gorilla.gif" "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Gorilla.gif"
"https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Arctic.gif", "https://monkelabs.nyc3.digitaloceanspaces.com/public/assets/LabMonke_Arctic.gif",
"https://smr-volume-1.s3.amazonaws.com/assets/4713.png", "https://smr-volume-1.s3.amazonaws.com/assets/4713.png",
"https://smr-volume-1.s3.amazonaws.com/assets/1739.png", "https://smr-volume-1.s3.amazonaws.com/assets/1739.png",
"https://smr-volume-1.s3.amazonaws.com/assets/5275.png", "https://smr-volume-1.s3.amazonaws.com/assets/5275.png",
"https://smr-volume-1.s3.amazonaws.com/assets/5796.png", "https://smr-volume-1.s3.amazonaws.com/assets/5796.png",
"https://www.arweave.net/shJMjP9y9mwFwmaTet0Jcok-dG1TEr8t7E362zeS6uM?ext=png" "https://www.arweave.net/shJMjP9y9mwFwmaTet0Jcok-dG1TEr8t7E362zeS6uM?ext=png"
"https://arweave.net/teqvJFiNG-_i7OHDwfeb5ISsGzN_SkU3jNQ7uzelJLo?ext=png", "https://arweave.net/teqvJFiNG-_i7OHDwfeb5ISsGzN_SkU3jNQ7uzelJLo?ext=png",
"https://arweave.net/giVsTWye2PILj1wZe3uP3VNRwvVbbLz-9-FJ94ToNv0?ext=png", "https://arweave.net/giVsTWye2PILj1wZe3uP3VNRwvVbbLz-9-FJ94ToNv0?ext=png",
"https://www.arweave.net/GciyPdeivlARIjnpQtFnFMVIVZTVUGEFt28ui-Yem9k?ext=png" "https://www.arweave.net/GciyPdeivlARIjnpQtFnFMVIVZTVUGEFt28ui-Yem9k?ext=png"
] ]
# Bot # Bot
intents = discord.Intents.all() intents = discord.Intents.all()
bot = commands.Bot(command_prefix='$', intents=intents) bot = commands.Bot(command_prefix='$', intents=intents)
# Logging # Logging
logger = logging.getLogger('discord') logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w') handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler) logger.addHandler(handler)
# Database # Database
schema = [ schema = [
'''CREATE TABLE IF NOT EXISTS collections ( '''CREATE TABLE IF NOT EXISTS collections (
id integer PRIMARY KEY, id integer PRIMARY KEY,
symbol text, symbol text,
image text, image text,
name text, name text,
description text, description text,
last_price integer last_price integer
)''', )''',
'''CREATE TABLE IF NOT EXISTS guilds ( '''CREATE TABLE IF NOT EXISTS guilds (
id integer PRIMARY KEY, id integer PRIMARY KEY,
guild_id integer guild_id integer
)''', )''',
'''CREATE TABLE IF NOT EXISTS lists ( '''CREATE TABLE IF NOT EXISTS lists (
collection_id integer, collection_id integer,
guild_id integer guild_id integer
)''' )'''
] ]
async def create_db(): async def create_db():
for query in schema: for query in schema:
await db.execute (query) await db.execute (query)
await db.commit() await db.commit()
print('Database ready') print('Database ready')
@bot.event @bot.event
async def on_ready(): async def on_ready():
global db global db
db = await aiosqlite.connect('db.sqlite3') db = await aiosqlite.connect('db.sqlite3')
await create_db() await create_db()
print('We have logged in as {0.user}'.format(bot)) print('We have logged in as {0.user}'.format(bot))
update_prices.start() update_prices.start()
await bot.change_presence(activity=discord.Game(name="The NFT Market")) await bot.change_presence(activity=discord.Game(name="The NFT Market"))
@bot.event @bot.event
async def on_guild_join(guild): async def on_guild_join(guild):
await db.execute('INSERT INTO guilds (guild_id) VALUES (?)', (guild.id,)) await db.execute('INSERT INTO guilds (guild_id) VALUES (?)', (guild.id,))
await db.commit() await db.commit()
print(f"Joined guild {guild.name}") print(f"Joined guild {guild.name}")
@bot.event @bot.event
async def on_guild_remove(guild): async def on_guild_remove(guild):
await db.execute('DELETE FROM guilds (guild_id) VALUES (?)', (guild.id,)) await db.execute('DELETE FROM guilds (guild_id) VALUES (?)', (guild.id,))
await db.execute('DELETE FROM lists (guild_id) VALUES (?)', (guild.id,)) await db.execute('DELETE FROM lists (guild_id) VALUES (?)', (guild.id,))
await db.commit() await db.commit()
print(f"Left guild {guild.name}") print(f"Left guild {guild.name}")
@bot.command(help='Lists all of your collections') @bot.command(help='Lists all of your collections')
async def list(ctx): async def list(ctx):
async with await db.execute("SELECT id from guilds WHERE guild_id=69 LIMIT 1") as cursor: async with await db.execute("SELECT id from guilds WHERE guild_id=69 LIMIT 1") as cursor:
print(cursor.rowcount) print(cursor.rowcount)
embed = discord.Embed(title='Here is a list of all your tracked collections', color=0x6106D0) embed = discord.Embed(title='Here is a list of all your tracked collections', color=0x6106D0)
embed.set_image(url=str(random.choice(NFT_LINKS))) embed.set_image(url=str(random.choice(NFT_LINKS)))
async with await db.execute("SELECT id from guilds WHERE guild_id=? LIMIT 1", (ctx.guild.id,)) as cursor: async with await db.execute("SELECT id from guilds WHERE guild_id=? LIMIT 1", (ctx.guild.id,)) as cursor:
async for row in cursor: async for row in cursor:
guild_id = row[0] guild_id = row[0]
collections = [] collections = []
async with await db.execute("SELECT collection_id from lists WHERE guild_id=?", (guild_id,)) as cursor: async with await db.execute("SELECT collection_id from lists WHERE guild_id=?", (guild_id,)) as cursor:
async for collection in cursor: async for collection in cursor:
collections.append(collection[0]) collections.append(collection[0])
print(collections) print(collections)
for collection_id in collections: for collection_id in collections:
async with await db.execute("SELECT symbol,name,last_price from collections WHERE id=? LIMIT 1", (collection_id,)) as cursor: async with await db.execute("SELECT symbol,name,last_price from collections WHERE id=? LIMIT 1", (collection_id,)) as cursor:
async for collection in cursor: async for collection in cursor:
embed.add_field(name=collection[1], value=f'`{collection[0]}` - {format_price(collection[2])}', inline=False) embed.add_field(name=collection[1], value=f'`{collection[0]}` - {format_price(collection[2])}', inline=False)
await ctx.send(embed=embed) await ctx.send(embed=embed)
@bot.command(brief='Add a collection to your list', help='Add a collection to your list, pass a symbol: magiceden.io/marketplace/SYMBOL', usage='SYMBOL') @bot.command(brief='Add a collection to your list', help='Add a collection to your list, pass a symbol: magiceden.io/marketplace/SYMBOL', usage='SYMBOL')
async def add(ctx, symbol): async def add(ctx, symbol):
data = requests.get(API_ENDPOINT + 'collections/' + symbol) data = requests.get(API_ENDPOINT + 'collections/' + symbol)
if data.status_code != 200: if data.status_code != 200:
await ctx.send(f'Could not find collection with symbol `{symbol}`') await ctx.send(f'Could not find collection with symbol `{symbol}`')
else: else:
price_data = requests.get(API_ENDPOINT + 'collections/' + symbol + '/stats').json() price_data = requests.get(API_ENDPOINT + 'collections/' + symbol + '/stats').json()
price = int(str(price_data['floorPrice'])[:-7]) price = int(str(price_data['floorPrice'])[:-7])
made = False made = False
async with await db.execute("SELECT id from collections WHERE symbol=?", (symbol,)) as cursor: async with await db.execute("SELECT id from collections WHERE symbol=?", (symbol,)) as cursor:
async for row in cursor: async for row in cursor:
made = True made = True
if not made: if not made:
await db.execute('INSERT INTO collections (symbol,image,name,last_price) VALUES (?,?,?,?)', (symbol,data.json()['image'],data.json()['name'],price)) await db.execute('INSERT INTO collections (symbol,image,name,last_price) VALUES (?,?,?,?)', (symbol,data.json()['image'],data.json()['name'],price))
await db.commit() await db.commit()
async with await db.execute("SELECT id FROM collections WHERE symbol=? LIMIT 1", (symbol,)) as cursor: async with await db.execute("SELECT id FROM collections WHERE symbol=? LIMIT 1", (symbol,)) as cursor:
async for row in cursor: async for row in cursor:
collection_id = row[0] collection_id = row[0]
async with await db.execute("SELECT id from guilds WHERE guild_id=? LIMIT 1", (ctx.guild.id,)) as cursor: async with await db.execute("SELECT id from guilds WHERE guild_id=? LIMIT 1", (ctx.guild.id,)) as cursor:
async for row in cursor: async for row in cursor:
guild_id = row[0] guild_id = row[0]
await db.execute('REPLACE INTO lists (guild_id, collection_id) VALUES (?,?)', (guild_id, collection_id)) await db.execute('REPLACE INTO lists (guild_id, collection_id) VALUES (?,?)', (guild_id, collection_id))
await db.commit() await db.commit()
await ctx.send(f'Added `{symbol}`({format_price(price)} ◎) to your list') await ctx.send(f'Added `{symbol}`({format_price(price)} ◎) to your list')
@bot.command(brief='Remove a collection from your list', help='Remove a collection from your list, pass a symbol: magiceden.io/marketplace/SYMBOL', usage='SYMBOL') @bot.command(brief='Remove a collection from your list', help='Remove a collection from your list, pass a symbol: magiceden.io/marketplace/SYMBOL', usage='SYMBOL')
async def remove(ctx, symbol): async def remove(ctx, symbol):
collection = None collection = None
async with await db.execute("SELECT id from collections WHERE symbol=?", (symbol,)) as cursor: async with await db.execute("SELECT id from collections WHERE symbol=?", (symbol,)) as cursor:
async for row in cursor: async for row in cursor:
collection = row[0] collection = row[0]
if collection is None: if collection is None:
await ctx.send(f'Could not find collection with symbol `{symbol}`') await ctx.send(f'Could not find collection with symbol `{symbol}`')
else: else:
await db.execute('DELETE FROM lists WHERE collection_id=?', (collection,)) await db.execute('DELETE FROM lists WHERE collection_id=?', (collection,))
await db.commit() await db.commit()
await ctx.send(f'Removed `{symbol}` from your list') await ctx.send(f'Removed `{symbol}` from your list')
@tasks.loop(seconds=10, minutes=0, hours=0, count=None) @tasks.loop(seconds=10, minutes=0, hours=0, count=None)
async def update_prices(): async def update_prices():
collections = [] collections = []
async with await db.execute("SELECT id,symbol,last_price,name from collections") as cursor: async with await db.execute("SELECT id,symbol,last_price,name from collections") as cursor:
async for row in cursor: async for row in cursor:
collections.append(row) collections.append(row)
prices = [] prices = []
changes = [] changes = []
for collection in collections: for collection in collections:
data = requests.get(API_ENDPOINT + 'collections/' + collection[1] + '/stats').json() data = requests.get(API_ENDPOINT + 'collections/' + collection[1] + '/stats').json()
price = int(str(data['floorPrice'])[:-7]) price = int(str(data['floorPrice'])[:-7])
prices.append((collection, price)) prices.append((collection, price))
if float(abs(price - collection[2])) > THRESHOLD*100: if float(abs(price - collection[2])) > THRESHOLD*100:
changes.append((collection, price)) changes.append((collection, price))
if len(changes) > 0: if len(changes) > 0:
print("We have a change!") print("We have a change!")
embed = discord.Embed(title='Price changes', color=0x6106D0) embed = discord.Embed(title='Price changes', color=0x6106D0)
embed.set_footer(text=f'Sent at {datetime.now().strftime("%d/%m/%Y %H:%M:%S")}', icon_url="https://imagedelivery.net/E-VnZk4fwouzlzwX_qz4fg/532afb9b-8805-424d-8f85-da5c3e0f8600/public") embed.set_footer(text=f'Sent at {datetime.now().strftime("%d/%m/%Y %H:%M:%S")}', icon_url="https://imagedelivery.net/E-VnZk4fwouzlzwX_qz4fg/532afb9b-8805-424d-8f85-da5c3e0f8600/public")
g_ids = [] g_ids = []
for change in changes: for change in changes:
if change[1] - change[0][2] > 0: if change[1] - change[0][2] > 0:
embed.add_field(name=f'{change[0][3]} (`{change[0][1]}`)', value=f'{format_price(change[0][2])} ◎ :arrow_right: {format_price(change[1])}\n:chart_with_upwards_trend:Change: {format_price(change[1] - change[0][2])}', inline=False) embed.add_field(name=f'{change[0][3]} (`{change[0][1]}`)', value=f'{format_price(change[0][2])} ◎ :arrow_right: {format_price(change[1])}\n:chart_with_upwards_trend:Change: {format_price(change[1] - change[0][2])}', inline=False)
else: else:
embed.add_field(name=f'{change[0][3]} (`{change[0][1]}`)', value=f'{format_price(change[0][2])} ◎ :arrow_right: {format_price(change[1])}\n:chart_with_downwards_trend:Change: {format_price(change[1] - change[0][2])}', inline=False) embed.add_field(name=f'{change[0][3]} (`{change[0][1]}`)', value=f'{format_price(change[0][2])} ◎ :arrow_right: {format_price(change[1])}\n:chart_with_downwards_trend:Change: {format_price(change[1] - change[0][2])}', inline=False)
collection_id = change[0][0] collection_id = change[0][0]
async with await db.execute("SELECT guild_id from lists WHERE collection_id=?", (collection_id,)) as cursor: async with await db.execute("SELECT guild_id from lists WHERE collection_id=?", (collection_id,)) as cursor:
async for row in cursor: async for row in cursor:
g_ids.append(row[0]) g_ids.append(row[0])
g_ids = set(g_ids) g_ids = set(g_ids)
guilds = [] guilds = []
for g_id in g_ids: for g_id in g_ids:
async with await db.execute("SELECT guild_id from guilds WHERE id=?", (g_id,)) as cursor: async with await db.execute("SELECT guild_id from guilds WHERE id=?", (g_id,)) as cursor:
async for row in cursor: async for row in cursor:
guilds.append(row[0]) guilds.append(row[0])
print("Sending to:", guilds) print("Sending to:", guilds)
for g_id in guilds: for g_id in guilds:
guild = bot.get_guild(g_id) guild = bot.get_guild(g_id)
channel_id = None channel_id = None
for c in guild.channels: for c in guild.channels:
if c.name == 'fp-changes': if c.name == 'fp-changes':
channel_id = c.id channel_id = c.id
channel = bot.get_channel(channel_id) channel = bot.get_channel(channel_id)
if channel_id is not None: if channel_id is not None:
await channel.send(embed=embed) await channel.send(embed=embed)
mention_role = discord.utils.get(guild.roles, name=MENTION_ROLE) mention_role = discord.utils.get(guild.roles, name=MENTION_ROLE)
if mention_role is not None: if mention_role is not None:
await channel.send(f'{mention_role.mention} `({", ".join([changes[i][0][1] for i in range(len(changes))])})`') await channel.send(f'{mention_role.mention} `({", ".join([changes[i][0][1] for i in range(len(changes))])})`')
for price in prices: for price in prices:
await db.execute('UPDATE collections SET last_price=? WHERE id=?', (price[1], price[0][0])) await db.execute('UPDATE collections SET last_price=? WHERE id=?', (price[1], price[0][0]))
await db.commit() await db.commit()
def format_price(price): def format_price(price):
if price == None: return 'NULL' if price == None: return 'NULL'
return f'{price/100}' return f'{price/100}'
bot.run(TOKEN) bot.run(TOKEN)