Skip to content

Commit

Permalink
Merge pull request #52 from RedCokeDevelopment/dev
Browse files Browse the repository at this point in the history
version 0.0.1.6
  • Loading branch information
RedTeaDev committed Jun 17, 2021
2 parents f3ba3ff + 9ca6c0e commit 998f9ff
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 122 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CONFIG_VERSION=0.1
BOT_TOKEN=
BOT_PREFIX=['/teapot ', '/tp ']
BOT_STATUS=f'{", ".join(teapot.config.bot_prefix())} | Teapot.py {teapot.version()}'
STORAGE_TYPE=flatfile

OSU_API_KEY=

DB_HOST=127.0.0.1
DB_PORT=3306
DB_SCHEMA=teapot
DB_USER=teapot
DB_PASSWORD=

LAVALINK_HOST=127.0.0.1
LAVALINK_PORT=2333
LAVALINK_PASSWORD=
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Teapot.py

on:
push:
branches:
- master
- "*"
pull_request:
branches:
- master
- dev


- "*"
jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8.0
- name: Set up Python 3.9.5
uses: actions/setup-python@v2
with:
python-version: 3.8.0
python-version: 3.9.5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 RedCoke Development
Copyright (c) 2020-2021 Red Coke Development

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ There are two owners for this project. They all contribute massively to the runn
- [RedTea](https://github.com/RedTeaDev) (RedTea#0001)

## 📜 Requirements
These are the requirements for the bot, and they will be bundled in future releases.
These are the requirements for the bot.

- [Python 3.8](https://www.python.org/downloads/release/python-382/) (Required packages listed in requirements.txt)
- [Python 3.9](https://www.python.org/downloads) (Required packages listed in requirements.txt)
- [LavaLink Server](https://github.com/freyacodes/lavalink) (Java 11 required)

## 💛 Credits
## 💖 Credits
The projects listed in below have provided inspiration, and we thought we'd mention them:

- LavaLink: https://github.com/freyacodes/lavalink
2 changes: 1 addition & 1 deletion Teapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

@bot.event
async def on_ready():
print(f"Connected to DiscordAPI in {round(time.perf_counter() - discord_time_start, 2)}s")
print(f"Connected to Discord API in {round(time.perf_counter() - discord_time_start, 2)}s")
time_start = time.perf_counter()
teapot.events.__init__(bot)
teapot.cogs.cmds.__init__(bot)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ beautifulsoup4>=4.9.1
bs4>=0.0.1
certifi>=2020.6.20
chardet>=3.0.4
discord.py>=1.5.1
discord.py>=1.7.2
idna>=2.10
lavalink>=3.1.2
multidict>=4.7.6
Expand Down
11 changes: 5 additions & 6 deletions teapot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import datetime
import platform
import socket
import sys

from .cogs import *
from .managers import *
from .tools import *
Expand All @@ -16,12 +21,10 @@ def config_version():


def time():
import datetime
return datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")


def year():
import datetime
return str(datetime.datetime.now().year)


Expand All @@ -33,20 +36,16 @@ def copyright():


def platform():
import platform
return platform.system() + " " + platform.release()


def hostname():
import socket
return socket.gethostname()


def ip():
import socket
return socket.gethostbyname(hostname())


def path():
import sys
return sys.path
4 changes: 2 additions & 2 deletions teapot/cogs/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, bot):

self.bot = bot

@commands.command(pass_context=True, aliases=['meow'])
@commands.command(aliases=['meow'])
async def cat(self, ctx):
""" Get a cat image """
req = requests.get('https://api.thecatapi.com/v1/images/search')
Expand All @@ -31,7 +31,7 @@ async def cat(self, ctx):
await ctx.send(embed=em)
await ctx.message.add_reaction(emoji='✅')

@commands.command(pass_context=True, aliases=['woof'])
@commands.command(aliases=['woof'])
async def dog(self, ctx):
""" Get a dog image """
req = requests.get('http://random.dog/')
Expand Down
122 changes: 61 additions & 61 deletions teapot/cogs/cmds.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
import discord
import time
import psutil
from discord.ext import commands as cmd

import teapot
import time
import typing


def __init__(bot):
""" Initialize commands """
helpcmd(bot)
info(bot)
ping(bot)
prune(bot)
kick(bot)
ban(bot)
admin(bot)
owner(bot)
debug(bot)
import teapot


def helpcmd(bot):
class Commands(discord.ext.commands.Cog):
def __init__(self, bot):
self.bot = bot

@bot.command(aliases=['?'])
async def help(ctx, *cog):
@discord.ext.commands.command(aliases=['?'])
async def help(self, ctx, *cog):
if not cog:
embed = discord.Embed(description="📖 Help", color=0x7400FF,
icon_url="https://cdn.discordapp.com/avatars/612634758744113182"
"/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
cogs_desc = ""
for x in bot.cogs:
cogs_desc += f'**{x}** - {bot.cogs[x].__doc__}\n'
for x in self.bot.cogs:
cogs_desc += f'**{x}** - {self.bot.cogs[x].__doc__}\n'
embed.add_field(name='Modules', value=cogs_desc[0:len(cogs_desc) - 1])
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
await ctx.send(embed=embed)
Expand All @@ -41,21 +31,21 @@ async def help(ctx, *cog):
await ctx.message.add_reaction(emoji='🛑')
else:
found = False
for x in bot.cogs:
for x in self.bot.cogs:
for y in cog:
if x == y:
embed = discord.Embed(color=0x7400FF)
cog_info = ''
for c in bot.get_cog(y).get_commands():
for c in self.bot.get_cog(y).get_commands():
if not c.hidden:
cog_info += f"**{c.name}** - {c.help}\n"
embed.add_field(name=f"{cog[0]} Module", value=cog_info)
await ctx.send(embed=embed)
await ctx.message.add_reaction(emoji='✅')
found = True
if not found:
for x in bot.cogs:
for c in bot.get_cog(x).get_commands():
for x in self.bot.cogs:
for c in self.bot.get_cog(x).get_commands():
if c.name.lower() == cog[0].lower():
embed = discord.Embed(title=f"Command: {c.name.lower().capitalize()}",
description=f"**Description:** {c.help}\n**Syntax:** {c.qualified_name} {c.signature}",
Expand All @@ -73,18 +63,17 @@ async def help(ctx, *cog):
await ctx.message.add_reaction(emoji='✅')


def info(bot):
@bot.command(aliases=['about'])
async def info(ctx):
@discord.ext.commands.command(aliases=['about'])
async def info(self, ctx):
embed = discord.Embed(title="Developers: RedTeaDev, ColaIan", description="Multi-purpose Discord Bot",
color=0x7400FF)
embed.set_author(name=f"Teapot.py {teapot.version()}",
icon_url="https://cdn.discordapp.com/avatars/612634758744113182"
"/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
embed.add_field(name="Bot User:", value=bot.user)
embed.add_field(name="Guilds:", value=len(bot.guilds))
embed.add_field(name="Members:", value=len(set(bot.get_all_members())))
embed.add_field(name="Bot User:", value=self.bot.user)
embed.add_field(name="Guilds:", value=len(self.bot.guilds))
embed.add_field(name="Members:", value=len(set(self.bot.get_all_members())))
embed.add_field(name="O.S.:", value=str(teapot.platform()))
embed.add_field(name="Storage Type:", value=teapot.config.storage_type())
embed.add_field(name="Prefix:", value=", ".join(teapot.config.bot_prefix()))
Expand All @@ -96,24 +85,22 @@ async def info(ctx):
"https://discordapp.com/oauth2/authorize?client_id=669880564270104586&permissions=8"
"&scope=bot) | [Repository](https://github.com/RedCokeDevelopment/Teapot.py)",
inline=False)
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under MIT License")
embed.set_image(
url="https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png")
await ctx.send(embed=embed)
await ctx.message.add_reaction(emoji='✅')


def ping(bot):
@bot.command()
async def ping(ctx):
await ctx.send(f'Pong! {round(bot.latency * 1000)} ms')
@discord.ext.commands.command()
async def ping(self, ctx):
await ctx.send(f'Pong! {round(self.bot.latency * 1000)} ms')
await ctx.message.add_reaction(emoji='✅')


def prune(bot):
@bot.command(aliases=['purge', 'clear', 'cls'])
@cmd.has_permissions(manage_messages=True)
async def prune(ctx, amount=0):
@discord.ext.commands.command(aliases=['purge', 'clear', 'cls'])
@discord.ext.commands.has_permissions(manage_messages=True)
async def prune(self, ctx, amount=0):
if amount == 0:
await ctx.send("Please specify the number of messages you want to delete!")
await ctx.message.add_reaction(emoji='❌')
Expand All @@ -125,10 +112,9 @@ async def prune(ctx, amount=0):
await ctx.channel.purge(limit=amount + 1)


def kick(bot):
@bot.command()
@cmd.has_permissions(kick_members=True) # check user permission
async def kick(ctx, member: discord.Member, *, reason=None):
@discord.ext.commands.command()
@discord.ext.commands.has_permissions(kick_members=True) # check user permission
async def kick(self, ctx, member: discord.Member, *, reason=None):
try:
await member.kick(reason=reason)
await ctx.send(f'{member} has been kicked!')
Expand All @@ -138,28 +124,39 @@ async def kick(ctx, member: discord.Member, *, reason=None):
await ctx.message.add_reaction(emoji='❌')


def ban(bot):
@bot.command()
@cmd.has_permissions(ban_members=True) # check user permission
async def ban(ctx, member: discord.Member, *, reason=None):
@discord.ext.commands.command()
@discord.ext.commands.has_permissions(ban_members=True) # check user permission
async def ban(self, ctx, member: typing.Any[discord.Member, discord.User], *, reason=None): # Banning a member who is not in the server is also possible
try:
await member.ban(reason=reason)
await ctx.send(f'{member} has been banned!')
if isinstance(member, discord.Member):
await member.ban(reason=reason)
else:
await ctx.guild.ban(member, reason=reason)

await ctx.send(f'{member.name} has been banned!')
await ctx.message.add_reaction(emoji='✅')
except Exception as e:
await ctx.send("Failed to ban: " + str(e))
await ctx.message.add_reaction(emoji='❌')

@discord.ext.commands.command()
@discord.ext.commands.has_permissions(ban_members=True) # check user permission
async def unban(self, ctx, member: discord.User, *, reason=None):
try:
await ctx.guild.unban(member, reason=reason)
await ctx.send(f'{member.name} has been unbanned!')
await ctx.message.add_reaction(emoji='✅')
except Exception as e:
await ctx.send("Failed to unban: " + str(e))
await ctx.message.add_reaction(emoji='❌')


def admin(bot): # WIP...
@bot.command()
async def admin(ctx):
@discord.ext.commands.command() # Work In Progress
async def admin(self, ctx):
await ctx.send(embed=teapot.messages.WIP())


def owner(bot):
@bot.command()
async def owner(ctx):
@discord.ext.commands.command()
async def owner(self, ctx):
if ctx.message.author.id == teapot.config.bot_owner():
found = False
for role in ctx.guild.roles:
Expand All @@ -176,16 +173,15 @@ async def owner(ctx):
break


def debug(bot):
@bot.command()
@cmd.has_permissions(administrator=True)
async def debug(ctx):
@discord.ext.commands.command()
@discord.ext.commands.has_permissions(administrator=True)
async def debug(self, ctx):
embed = discord.Embed(title="Developers: RedTea, ColaIan", description="Debug info:",
color=0x7400FF)
embed.set_author(name=f"Teapot.py {teapot.version()}",
icon_url="https://cdn.discordapp.com/avatars/612634758744113182/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
embed.add_field(name="Bot User:", value=bot.user, inline=True)
embed.add_field(name="Bot User:", value=self.bot.user, inline=True)
embed.add_field(name="System Time:", value=time.strftime("%a %b %d %H:%M:%S %Y", time.localtime()), inline=True)
embed.add_field(name="Memory",
value=str(round(psutil.virtual_memory()[1] / 1024 / 1024 / 1024)) + "GB / " + str(round(
Expand All @@ -205,3 +201,7 @@ async def debug(ctx):
# embed.set_image(url="https://user-images.githubusercontent.com/43201383/72987537-89830a80-3e25-11ea-95ef-ecfa0afcff7e.png")
await ctx.message.author.send(embed=embed)
await ctx.message.add_reaction(emoji='✅')


def setup(bot):
bot.add_cog(Commands(bot))
Loading

0 comments on commit 998f9ff

Please sign in to comment.