Last active
October 15, 2016 17:05
-
-
Save NotSoSuper/cf97e713a61548b577f0649243621c7b to your computer and use it in GitHub Desktop.
you need your own token but whatever
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oauth_regex = r"^https:\/\/discordapp\.com\/oauth2\/authorize\?client_id=(\d+)" | |
@commands.command(pass_context=True, aliases=['addbot']) | |
@commands.bot_has_permissions(manage_server=True) | |
async def oauth(self, ctx, url:str): | |
regex = re.compile(self.oauth_regex) | |
match = regex.findall(url) | |
if len(match) == 1: | |
client_id = match[0] | |
else: | |
await self.bot.say(":exclamation: Invalid OAUTH URL") | |
return | |
oauth_url = "https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot".format(client_id) | |
payload = {"guild_id": ctx.message.server.id, "permissions": 0, "authorize": 'true'} | |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:43.0) Gecko/20100101 Firefox/43.0', 'authorization': self.bot.http.token} | |
r = requests.post(oauth_url, data=payload, headers=headers) | |
print(r.text) | |
print(r.json()) | |
if discord.Server.get_member(ctx.message.server, user_id=client_id): | |
bot_user = discord.Server.get_member(ctx.message.server, user_id=client_id) | |
msg = "Name: {0}\n".format(bot_user.name) | |
msg += "ID: {0}\n".format(bot_user.id) | |
if bot_user.avatar: | |
msg += "Avatar: {0}".format(bot_user.avatar_url) | |
await self.bot.say(cool.format(msg)+":ok:") | |
else: | |
await self.bot.say(":warning: An Error has Occured While Attempting To Add The Bot") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment