Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit 8439543

Browse files
authored
Merge pull request #1 from verixx/rewrite
update
2 parents 3f2db66 + 8d6bf7d commit 8439543

File tree

11 files changed

+437
-84
lines changed

11 files changed

+437
-84
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p> <img src="https://i.imgur.com/lBSqWgt.png"/> </p>
33
<p><i><b>Moderation, fun, utility and much more! (Rewrite)</b></i></p>
44
<p>
5-
<a href="https://discord.gg/pmQSbAd"><img src="https://discordapp.com/api/guilds/345787308282478592/widget.png?style=banner2" alt="" /></a>
5+
<a href="https://discord.gg/2B4UvKx"><img src="https://discordapp.com/api/guilds/376697605029101569/widget.png?style=banner2" alt="" /></a>
66
</p>
77
<p> <img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="passing" /></a>
88
<img src="https://img.shields.io/badge/python-3.6-brightgreen.svg" alt="python 3.6" /></a>
@@ -40,6 +40,6 @@ Currently available cogs:-
4040

4141
Note: You **do not** have to add default cogs into `data/community_cogs.txt`.
4242

43-
## Acknowledgements
43+
## Acknowledgements
4444

4545
> Eval and google commands by [Rapptz](https://github.com/Rapptz) from R.Danny

cogs/gitcog.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import discord
2+
from discord.ext import commands
3+
import os
4+
import json
5+
import aiohttp
6+
import traceback
7+
8+
class Git:
9+
'''Github Cog, facilitates viewing and creating issues'''
10+
def __init__(self, bot):
11+
self.bot = bot
12+
self.session = aiohttp.ClientSession()
13+
14+
@property
15+
def githubtoken(self):
16+
'''
17+
Returns your token wherever it is
18+
19+
This token can give any user complete access to the account.
20+
https://github.com/settings/tokens is where you make a token.
21+
'''
22+
with open('data/config.json') as f:
23+
config = json.load(f)
24+
return os.environ.get('GITHUBTOKEN') or config.get('GITHUBTOKEN')
25+
26+
async def githubusername(self):
27+
'''Returns Github Username'''
28+
async with self.session.get('https://api.github.com/user', headers={"Authorization": f"Bearer {self.githubtoken}"}) as resp: #get username
29+
if 300 > resp.status >= 200:
30+
return (await resp.json())['login']
31+
32+
async def starred(self, repo):
33+
async with self.session.get('https://api.github.com/user/starred/' + repo, headers={"Authorization": f"Bearer {self.githubtoken}"}) as resp:
34+
if resp.status == 204:
35+
return True
36+
if resp.status == 404:
37+
return False
38+
39+
@commands.command()
40+
async def issue(self, ctx, repo, issueid):
41+
'''View an issue from Github!'''
42+
async with ctx.session.get(f"https://api.github.com/repos/{repo}/issues/{issueid}") as resp:
43+
if resp.status == 200 or resp.status == 201:
44+
issueinfo = await resp.json()
45+
else:
46+
return await ctx.send('ConnectionError: Github API Issue.')
47+
async with ctx.session.get(issueinfo['comments_url']) as resp:
48+
if resp.status == 200 or resp.status == 201:
49+
commentsinfo = await resp.json()
50+
else:
51+
return await ctx.send('ConnectionError: Github API Issue.')
52+
53+
if issueinfo['state'] == 'closed': colour = 0xcb2431
54+
elif issueinfo['state'] == 'open': colour = 0x2cbe4e
55+
else: colour = 0xffffff
56+
try:
57+
issueinfo['pull_request']
58+
except KeyError:
59+
issuetype = 'Issue'
60+
else:
61+
issuetype = 'Pull Request'
62+
em = discord.Embed(title=issueinfo['title'] + ' (#' + str(issueinfo['number']) + ')', description=issueinfo['body'], url=issueinfo['html_url'], color=colour)
63+
em.set_author(name=issueinfo['user']['login'] + ' (' + issueinfo['author_association'].capitalize() + ')', icon_url=issueinfo['user']['avatar_url'])
64+
em.set_footer(text=issuetype + ' | ' + issueinfo['created_at'])
65+
for comment in commentsinfo:
66+
em.add_field(name=comment['user']['login'] + ' (' + comment['author_association'].capitalize() + ')', value=comment['body'], inline=False)
67+
await ctx.send(embed=em)
68+
69+
@commands.command()
70+
async def makeissue(self, ctx, repo, title, *, body):
71+
'''Create an issue! `{}makeissue <title> | <body>`'''.format(ctx.prefix)
72+
async with ctx.session.post(f'https://api.github.com/repos/{repo}/issues', json={"title": title, "body": body}, headers={'Authorization': f'Bearer {self.githubtoken}'}) as resp:
73+
if resp.status == 200 or resp.status == 201:
74+
issueinfo = await resp.json()
75+
else:
76+
return await ctx.send('ConnectionError: Github API Issue.')
77+
78+
em = discord.Embed(title=issueinfo['title'] + ' (#' + str(issueinfo['number']) + ')', description=issueinfo['body'], url=issueinfo['html_url'], color=0xcb2431)
79+
em.set_author(name=issueinfo['user']['login'] + ' (' + issueinfo['author_association'].capitalize() + ')', icon_url=issueinfo['user']['avatar_url'])
80+
em.set_footer(text='Issue | ' + issueinfo['created_at'])
81+
await ctx.send(embed=em)
82+
83+
@commands.command()
84+
async def comment(self, ctx, repo, issueid:int, *, content):
85+
'''Comment on a Github Issue'''
86+
async with ctx.session.post(f'https://api.github.com/repos/{repo}/issues/{issueid}/comments', json={"body": content}, headers={'Authorization': f'Bearer {self.githubtoken}'}) as resp:
87+
if resp.status != 200 and resp.status != 201:
88+
return await ctx.send('ConnectionError: Github API Issue.')
89+
await ctx.send('Submitted comment to issue ' + str(issueid))
90+
91+
def setup(bot):
92+
bot.add_cog(Git(bot))

cogs/info.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import psutil
3232
import random
3333
import pip
34+
import json
3435
import os
3536
import io
3637

@@ -40,26 +41,36 @@ def __init__(self, bot):
4041
self.bot = bot
4142

4243
@commands.command(no_pm=True)
43-
async def channels(self, ctx):
44+
async def channels(self, ctx, serverid:int = None):
4445
"""Shows ALL channels, use wisely!"""
4546

47+
if serverid is None:
48+
server = ctx.guild
49+
else:
50+
server = discord.utils.get(self.bot.guilds, id=serverid)
51+
if server is None:
52+
return await ctx.send('Server not found!')
53+
4654
e = discord.Embed()
4755
e.color = await ctx.get_dominant_color()
4856

4957
voice = ''
5058
text = ''
5159
categories = ''
5260

53-
for channel in ctx.guild.voice_channels:
61+
for channel in server.voice_channels:
5462
voice += f'\U0001f508 {channel}\n'
55-
for channel in ctx.guild.categories:
63+
for channel in server.categories:
5664
categories += f'\U0001f4da {channel}\n'
57-
for channel in ctx.guild.text_channels:
65+
for channel in server.text_channels:
5866
text += f'\U0001f4dd {channel}\n'
5967

60-
e.add_field(name='Text Channels', value=f'```{text}```')
61-
e.add_field(name='Categories', value=f'```{categories}```')
62-
e.add_field(name='Voice Channels', value=f'```{voice}```')
68+
if len(server.text_channels) > 0:
69+
e.add_field(name='Text Channels', value=f'```{text}```')
70+
if len(server.categories) > 0:
71+
e.add_field(name='Categories', value=f'```{categories}```')
72+
if len(server.voice_channels) > 0:
73+
e.add_field(name='Voice Channels', value=f'```{voice}```')
6374

6475
try:
6576
await ctx.send(embed=e)
@@ -188,6 +199,32 @@ async def serverinfo(self, ctx, server_id : int=None):
188199
for page in em_list:
189200
await ctx.send(page)
190201

202+
@commands.command()
203+
async def tags(self, ctx, *, text: str=None):
204+
''' Get useful selfbot tags & tutorials '''
205+
try:
206+
await ctx.message.delete()
207+
except discord.Forbidden:
208+
pass
209+
with open('data/tags.json', 'r') as f:
210+
s = f.read()
211+
tags = json.loads(s)
212+
if text in tags:
213+
await ctx.send(f'{tags[str(text)]}')
214+
else:
215+
p = f' {ctx.prefix}{ctx.invoked_with} '
216+
usage = f'\n***AVAILABLE TAGS:***\n\n' \
217+
f'`1.`{p}heroku\n`2.`{p}change-token\n' \
218+
f'`3.`{p}hosting\n`4.`{p}rules-selfbot\n`5.`{p}tutorial\n' \
219+
f'`6.`{p}update\n`7.`{p}support-invite\n`8.`{p}support\n' \
220+
f'`9.`{p}android-token\n`10.`{p}android-heroku'
221+
e = discord.Embed()
222+
e.color = await ctx.get_dominant_color(url=ctx.message.author.avatar_url)
223+
e.add_field(name='Tag not found!', value=usage)
224+
try:
225+
await ctx.send(embed=e, delete_after=15)
226+
except Exception as e:
227+
await ctx.send(f'```{e}```')
191228

192229
@commands.command(aliases=['ui'], no_pm=True)
193230
@commands.guild_only()
@@ -262,7 +299,7 @@ async def about(self, ctx):
262299
uptime = fmt.format(d=days, h=hours, m=minutes, s=seconds)
263300

264301
github = '[Click Here](https://github.com/verixx/selfbot.py/)'
265-
server = '[Click Here](https://discord.gg/pmQSbAd)'
302+
server = '[Click Here](https://discord.gg/2B4UvKx)'
266303
website = '[selfbot-py.tk](http://selfbot-py.tk/)'
267304

268305

cogs/misc.py

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -338,37 +338,23 @@ async def dcolor(self, ctx, *, url):
338338
await ctx.send(file=discord.File(file, 'color.png'), embed=em)
339339

340340
@commands.command(description='This command might get you banned')
341-
async def annoy(self, ctx, *, member=None, times: int = None):
342-
"""Want to annoy a member with mentions?"""
343-
channel = ctx.message.channel
344-
author = ctx.message.author
345-
message = ctx.message
346-
usage = f'```Usage: {ctx.prefix}ultimate_annoying_spam_command [@member] [times]```'
347-
348-
if member or times is None:
349-
await ctx.channel.send(usage)
350-
return
351-
352-
if times > 100:
353-
times = 35
354-
355-
if times is 0:
356-
sorry = f'Someone, not saying who, *cough cough {author}* felt sorry about using this command.'
357-
await ctx.channel.send(sorry)
358-
return
359-
360-
if times < 0:
361-
chicken = "Well, that's just not enough times to annoy anybody. Don't chicken out now!"
362-
await ctx.channel.send(chicken)
363-
return
364-
365-
await message.delete()
366-
367-
for i in range(0, times):
368-
try:
369-
await channel.send(f'{member.mention} LOL')
370-
except Exception:
371-
pass
341+
async def annoy(self, ctx, member: discord.Member=None, number: int=5):
342+
""" Usage: annoy @b1nzy#1337 50
343+
NOTICE: If you get banned, don't come back crying! """
344+
if number > 5:
345+
number = 5
346+
member = member or ctx.author
347+
try:
348+
await ctx.message.delete()
349+
except discord.Forbidden:
350+
pass
351+
if member != None:
352+
for x in range(number):
353+
await ctx.channel.trigger_typing()
354+
await ctx.send(member.mention)
355+
await asyncio.sleep(8)
356+
else:
357+
return await ctx.send(f"{ctx.author.mention}, I don't know how to use commands. Help!")
372358

373359
@commands.command()
374360
async def tinyurl(self, ctx, *, link: str):

cogs/mod.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import pip
3232
import os
3333
import io
34+
import json
3435

3536

3637
class Mod:
@@ -40,7 +41,7 @@ def __init__(self, bot):
4041

4142
async def format_mod_embed(self, ctx, user, success, method, duration = None, location=None):
4243
'''Helper func to format an embed to prevent extra code'''
43-
emb = discord.Embed()
44+
emb = discord.Embed(timestamp=ctx.message.created_at)
4445
emb.set_author(name=method.title(), icon_url=user.avatar_url)
4546
emb.color = await ctx.get_dominant_color(user.avatar_url)
4647
emb.set_footer(text=f'User ID: {user.id}')
@@ -60,7 +61,19 @@ async def format_mod_embed(self, ctx, user, success, method, duration = None, lo
6061
emb.description = f"You do not have the permissions to {method} `{location.name}`."
6162
else:
6263
emb.description = f"You do not have the permissions to {method} {user.name}."
63-
64+
65+
with open('data/config.json') as f:
66+
config = json.load(f)
67+
modlog = os.environ.get('MODLOG') or config.get('MODLOG')
68+
if modlog is None:
69+
await ctx.send('You have not set `MODLOG` in your config vars.', delete_after=5)
70+
else:
71+
modlog = discord.utils.get(self.bot.get_all_channels(), id=int(modlog))
72+
if modlog is None:
73+
await ctx.send('Your `MODLOG` channel ID is invalid.', delete_after=5)
74+
else:
75+
await modlog.send(embed=emb)
76+
6477
return emb
6578

6679
@commands.command()
@@ -108,9 +121,14 @@ async def unban(self, ctx, name_or_id, *, reason=None):
108121
await ctx.send(embed=emb)
109122

110123
@commands.command(aliases=['del','p','prune'])
111-
async def purge(self, ctx, limit : int):
124+
async def purge(self, ctx, limit : int, member:discord.Member=None):
112125
'''Clean a number of messages'''
113-
await ctx.purge(limit=limit+1) # TODO: add more functionality
126+
if member is None:
127+
await ctx.purge(limit=limit+1)
128+
else:
129+
async for message in ctx.channel.history(limit=limit+1):
130+
if message.author is member:
131+
await message.delete()
114132

115133
@commands.command()
116134
async def clean(self, ctx, limit : int=15):

0 commit comments

Comments
 (0)