2023-06-19 16:39:15 -04:00
|
|
|
import asyncio
|
|
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
import aiohttp
|
|
|
|
import revolt
|
|
|
|
from revolt.ext import commands
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
token = os.getenv('TOKEN')
|
|
|
|
api_url = os.getenv('API_URL')
|
2023-06-19 16:47:48 -04:00
|
|
|
prefix = os.getenv('PREFIX')
|
2023-06-19 16:39:15 -04:00
|
|
|
|
|
|
|
class Client(commands.CommandsClient):
|
2023-06-19 17:15:19 -04:00
|
|
|
# This class contains all of the commands the bot uses.
|
2023-06-19 16:39:15 -04:00
|
|
|
async def get_prefix(self, message: revolt.Message):
|
2023-06-19 16:47:48 -04:00
|
|
|
return prefix
|
2023-06-19 17:15:19 -04:00
|
|
|
|
2023-06-19 16:39:15 -04:00
|
|
|
@commands.command()
|
|
|
|
async def ping(self, ctx: commands.Context):
|
2023-06-19 17:11:20 -04:00
|
|
|
# Checks if the bot is running.
|
2023-06-19 16:39:15 -04:00
|
|
|
await ctx.send("Pong!")
|
|
|
|
|
|
|
|
@commands.command()
|
|
|
|
async def avatar(self, ctx: commands.Context, member: revolt.Member):
|
2023-06-19 17:11:20 -04:00
|
|
|
# Checks a user's avatar.
|
2023-06-19 16:39:15 -04:00
|
|
|
if not isinstance(member, revolt.Member):
|
|
|
|
await ctx.send("Please provide a member argument!")
|
|
|
|
return
|
|
|
|
avatar = member.avatar.url
|
|
|
|
await ctx.send(f"{avatar}")
|
|
|
|
|
|
|
|
async def main():
|
2023-06-19 17:11:20 -04:00
|
|
|
# This function logs into the bot user.
|
2023-06-19 16:39:15 -04:00
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
client = Client(session, token, api_url=api_url)
|
|
|
|
await client.start()
|
|
|
|
|
2023-06-19 17:11:20 -04:00
|
|
|
asyncio.run(main())
|