Created
January 25, 2018 19:23
-
-
Save yhdesai/541d96a27d08ca307a6e48ff92ddc2ed to your computer and use it in GitHub Desktop.
techie bot
This file contains hidden or 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
import time #Importing the time library to check the time of code execution | |
import sys #Importing the System Library | |
import os | |
import requests | |
#import urllib2 | |
import discord | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) | |
print(client.user.id) | |
print('------') | |
@client.event | |
async def on_message(message): | |
if message.author == client.user: | |
return | |
if message.content.startswith(''): | |
#author = message.author #member (object) | |
#authorid = message.author.id #member id (string) | |
#content = message.content #content (string) | |
#role_member = message.server.roles[3] #member role (object) | |
if message.content.startswith('!ping'): | |
await client.send_message(message.channel, 'Pong') | |
if message.content.startswith('!pong'): | |
await client.send_message(message.channel, 'Ping') | |
if message.content.startswith ('!role'): | |
content = message.content[6:] | |
for role in message.server.roles: | |
if role.name.lower() == content: | |
role_member = role | |
await client.add_roles(author, role_member) | |
await client.send_message(message.channel, "You've been granted the role") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment