Skip to content

Instantly share code, notes, and snippets.

@aeshthetic
Created January 7, 2017 04:09
Show Gist options
  • Save aeshthetic/c61ebc15d33a228bcf0a8ca6e266bac3 to your computer and use it in GitHub Desktop.
Save aeshthetic/c61ebc15d33a228bcf0a8ca6e266bac3 to your computer and use it in GitHub Desktop.
import discord
from discord.ext import commands
import random
description = '''An example bot to showcase the discord.ext.commands extension
module.
There are a number of utility commands being showcased here.'''
bot = commands.Bot(command_prefix='?', description=description)
def getRole(server: discord.Server, role_name: str):
'''Gets and returns a role in a server'''
role = discord.utils.get(server.roles, name=role_name)
print(role)
return role
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command(pass_context=True)
async def join(ctx, position):
author = ctx.message.author
bot.add_roles(author, getRole(ctx.message.server, "player"))
@bot.command()
async def add(left : int, right : int):
"""Adds two numbers together."""
await bot.say(left + right)
@bot.event
async def on_member_join(member):
server = member.server
fmt = 'Welcome {0.mention} to {1.name}! Please type in ?join [position] to gain access to other channels on the server!'
await client.send_message(server, fmt.format(member, server))
bot.run('token')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment