Skip to content

Commit 998f9ff

Browse files
author
RedTea
authored
Merge pull request #52 from RedCokeDevelopment/dev
version 0.0.1.6
2 parents f3ba3ff + 9ca6c0e commit 998f9ff

File tree

13 files changed

+140
-122
lines changed

13 files changed

+140
-122
lines changed

.env.example

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CONFIG_VERSION=0.1
2+
BOT_TOKEN=
3+
BOT_PREFIX=['/teapot ', '/tp ']
4+
BOT_STATUS=f'{", ".join(teapot.config.bot_prefix())} | Teapot.py {teapot.version()}'
5+
STORAGE_TYPE=flatfile
6+
7+
OSU_API_KEY=
8+
9+
DB_HOST=127.0.0.1
10+
DB_PORT=3306
11+
DB_SCHEMA=teapot
12+
DB_USER=teapot
13+
DB_PASSWORD=
14+
15+
LAVALINK_HOST=127.0.0.1
16+
LAVALINK_PORT=2333
17+
LAVALINK_PASSWORD=

.github/workflows/python-app.yml renamed to .github/workflows/Teapot.py.yml

+4-10
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,22 @@
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

44
name: Teapot.py
5-
65
on:
76
push:
87
branches:
9-
- master
8+
- "*"
109
pull_request:
1110
branches:
12-
- master
13-
- dev
14-
15-
11+
- "*"
1612
jobs:
1713
build:
18-
1914
runs-on: ubuntu-latest
20-
2115
steps:
2216
- uses: actions/checkout@v2
23-
- name: Set up Python 3.8.0
17+
- name: Set up Python 3.9.5
2418
uses: actions/setup-python@v2
2519
with:
26-
python-version: 3.8.0
20+
python-version: 3.9.5
2721
- name: Install dependencies
2822
run: |
2923
python -m pip install --upgrade pip

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 RedCoke Development
3+
Copyright (c) 2020-2021 Red Coke Development
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ There are two owners for this project. They all contribute massively to the runn
4949
- [RedTea](https://github.com/RedTeaDev) (RedTea#0001)
5050

5151
## 📜 Requirements
52-
These are the requirements for the bot, and they will be bundled in future releases.
52+
These are the requirements for the bot.
5353

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

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

6060
- LavaLink: https://github.com/freyacodes/lavalink

Teapot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
@bot.event
9292
async def on_ready():
93-
print(f"Connected to DiscordAPI in {round(time.perf_counter() - discord_time_start, 2)}s")
93+
print(f"Connected to Discord API in {round(time.perf_counter() - discord_time_start, 2)}s")
9494
time_start = time.perf_counter()
9595
teapot.events.__init__(bot)
9696
teapot.cogs.cmds.__init__(bot)

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ beautifulsoup4>=4.9.1
55
bs4>=0.0.1
66
certifi>=2020.6.20
77
chardet>=3.0.4
8-
discord.py>=1.5.1
8+
discord.py>=1.7.2
99
idna>=2.10
1010
lavalink>=3.1.2
1111
multidict>=4.7.6

teapot/__init__.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import datetime
2+
import platform
3+
import socket
4+
import sys
5+
16
from .cogs import *
27
from .managers import *
38
from .tools import *
@@ -16,12 +21,10 @@ def config_version():
1621

1722

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

2226

2327
def year():
24-
import datetime
2528
return str(datetime.datetime.now().year)
2629

2730

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

3437

3538
def platform():
36-
import platform
3739
return platform.system() + " " + platform.release()
3840

3941

4042
def hostname():
41-
import socket
4243
return socket.gethostname()
4344

4445

4546
def ip():
46-
import socket
4747
return socket.gethostbyname(hostname())
4848

4949

5050
def path():
51-
import sys
5251
return sys.path

teapot/cogs/cat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, bot):
1616

1717
self.bot = bot
1818

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

34-
@commands.command(pass_context=True, aliases=['woof'])
34+
@commands.command(aliases=['woof'])
3535
async def dog(self, ctx):
3636
""" Get a dog image """
3737
req = requests.get('http://random.dog/')

teapot/cogs/cmds.py

+61-61
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
import discord
2-
import time
32
import psutil
4-
from discord.ext import commands as cmd
5-
6-
import teapot
3+
import time
4+
import typing
75

86

9-
def __init__(bot):
10-
""" Initialize commands """
11-
helpcmd(bot)
12-
info(bot)
13-
ping(bot)
14-
prune(bot)
15-
kick(bot)
16-
ban(bot)
17-
admin(bot)
18-
owner(bot)
19-
debug(bot)
7+
import teapot
208

219

22-
def helpcmd(bot):
10+
class Commands(discord.ext.commands.Cog):
11+
def __init__(self, bot):
12+
self.bot = bot
2313

24-
@bot.command(aliases=['?'])
25-
async def help(ctx, *cog):
14+
@discord.ext.commands.command(aliases=['?'])
15+
async def help(self, ctx, *cog):
2616
if not cog:
2717
embed = discord.Embed(description="📖 Help", color=0x7400FF,
2818
icon_url="https://cdn.discordapp.com/avatars/612634758744113182"
2919
"/7fe078b5ea6b43000dfb7964e3e4d21d.png?size=512")
3020
embed.set_thumbnail(url="https://avatars2.githubusercontent.com/u/60006969?s=200&v=4")
3121
cogs_desc = ""
32-
for x in bot.cogs:
33-
cogs_desc += f'**{x}** - {bot.cogs[x].__doc__}\n'
22+
for x in self.bot.cogs:
23+
cogs_desc += f'**{x}** - {self.bot.cogs[x].__doc__}\n'
3424
embed.add_field(name='Modules', value=cogs_desc[0:len(cogs_desc) - 1])
3525
embed.set_footer(text=f"{teapot.copyright()} | Code licensed under the MIT License")
3626
await ctx.send(embed=embed)
@@ -41,21 +31,21 @@ async def help(ctx, *cog):
4131
await ctx.message.add_reaction(emoji='🛑')
4232
else:
4333
found = False
44-
for x in bot.cogs:
34+
for x in self.bot.cogs:
4535
for y in cog:
4636
if x == y:
4737
embed = discord.Embed(color=0x7400FF)
4838
cog_info = ''
49-
for c in bot.get_cog(y).get_commands():
39+
for c in self.bot.get_cog(y).get_commands():
5040
if not c.hidden:
5141
cog_info += f"**{c.name}** - {c.help}\n"
5242
embed.add_field(name=f"{cog[0]} Module", value=cog_info)
5343
await ctx.send(embed=embed)
5444
await ctx.message.add_reaction(emoji='✅')
5545
found = True
5646
if not found:
57-
for x in bot.cogs:
58-
for c in bot.get_cog(x).get_commands():
47+
for x in self.bot.cogs:
48+
for c in self.bot.get_cog(x).get_commands():
5949
if c.name.lower() == cog[0].lower():
6050
embed = discord.Embed(title=f"Command: {c.name.lower().capitalize()}",
6151
description=f"**Description:** {c.help}\n**Syntax:** {c.qualified_name} {c.signature}",
@@ -73,18 +63,17 @@ async def help(ctx, *cog):
7363
await ctx.message.add_reaction(emoji='✅')
7464

7565

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

10594

106-
def ping(bot):
107-
@bot.command()
108-
async def ping(ctx):
109-
await ctx.send(f'Pong! {round(bot.latency * 1000)} ms')
95+
@discord.ext.commands.command()
96+
async def ping(self, ctx):
97+
await ctx.send(f'Pong! {round(self.bot.latency * 1000)} ms')
11098
await ctx.message.add_reaction(emoji='✅')
11199

112100

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

127114

128-
def kick(bot):
129-
@bot.command()
130-
@cmd.has_permissions(kick_members=True) # check user permission
131-
async def kick(ctx, member: discord.Member, *, reason=None):
115+
@discord.ext.commands.command()
116+
@discord.ext.commands.has_permissions(kick_members=True) # check user permission
117+
async def kick(self, ctx, member: discord.Member, *, reason=None):
132118
try:
133119
await member.kick(reason=reason)
134120
await ctx.send(f'{member} has been kicked!')
@@ -138,28 +124,39 @@ async def kick(ctx, member: discord.Member, *, reason=None):
138124
await ctx.message.add_reaction(emoji='❌')
139125

140126

141-
def ban(bot):
142-
@bot.command()
143-
@cmd.has_permissions(ban_members=True) # check user permission
144-
async def ban(ctx, member: discord.Member, *, reason=None):
127+
@discord.ext.commands.command()
128+
@discord.ext.commands.has_permissions(ban_members=True) # check user permission
129+
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
145130
try:
146-
await member.ban(reason=reason)
147-
await ctx.send(f'{member} has been banned!')
131+
if isinstance(member, discord.Member):
132+
await member.ban(reason=reason)
133+
else:
134+
await ctx.guild.ban(member, reason=reason)
135+
136+
await ctx.send(f'{member.name} has been banned!')
148137
await ctx.message.add_reaction(emoji='✅')
149138
except Exception as e:
150139
await ctx.send("Failed to ban: " + str(e))
151140
await ctx.message.add_reaction(emoji='❌')
141+
142+
@discord.ext.commands.command()
143+
@discord.ext.commands.has_permissions(ban_members=True) # check user permission
144+
async def unban(self, ctx, member: discord.User, *, reason=None):
145+
try:
146+
await ctx.guild.unban(member, reason=reason)
147+
await ctx.send(f'{member.name} has been unbanned!')
148+
await ctx.message.add_reaction(emoji='✅')
149+
except Exception as e:
150+
await ctx.send("Failed to unban: " + str(e))
151+
await ctx.message.add_reaction(emoji='❌')
152152

153-
154-
def admin(bot): # WIP...
155-
@bot.command()
156-
async def admin(ctx):
153+
@discord.ext.commands.command() # Work In Progress
154+
async def admin(self, ctx):
157155
await ctx.send(embed=teapot.messages.WIP())
158156

159157

160-
def owner(bot):
161-
@bot.command()
162-
async def owner(ctx):
158+
@discord.ext.commands.command()
159+
async def owner(self, ctx):
163160
if ctx.message.author.id == teapot.config.bot_owner():
164161
found = False
165162
for role in ctx.guild.roles:
@@ -176,16 +173,15 @@ async def owner(ctx):
176173
break
177174

178175

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

0 commit comments

Comments
 (0)