Commit 9d71a2cc authored by Ferdinand Schober's avatar Ferdinand Schober 💬
Browse files

Split into several cogs

parent be095ac2
import discord
from discord.ext import commands
class Util(commands.Cog):
@commands.Cog.listener()
async def on_member_join(self, member):
print(f'{member} has joined a server')
@commands.Cog.listener()
async def on_member_remove(self, member):
print(f'{member} has left a server')
@commands.command()
async def echo(self, ctx, *, args):
await ctx.send(args)
@commands.command()
async def ping(self, ctx):
await ctx.send('pong')
@commands.command()
async def clear(self, ctx, amount=2):
await ctx.channel.purge(limit=amount)
def setup(client):
client.add_cog(Util(client))
\ No newline at end of file
import discord
from discord.ext import commands
class Werewolf(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
self.commands_channel = await self.client.fetch_channel(696105930336632963)
self.info_channel = await self.client.fetch_channel(696130399860162626)
self.lobby = await self.client.fetch_channel(696130304884211733)
self.welcome_channel = await self.client.fetch_channel(696079221684175005)
self.werewolf_channel = await self.client.fetch_channel(696088648365375570)
@commands.command()
async def restart_game(self, ctx):
if ctx.channel != self.commands_channel: return
await self.commands_channel.send('restarting game!')
await self.init_game(self.lobby.members)
async def init_game(self, players):
info = f'starting new game with {[member.name for member in players]}'
print(info)
await self.commands_channel.send(info)
self.game = game(players)
def game(players): return ''
def setup(client):
client.add_cog(Werewolf(client))
\ No newline at end of file
import discord
import asyncio
from pprint import pprint
from discord.ext import commands
bot = commands.Bot(command_prefix='$')
@bot.event
async def on_ready():
print('Bot is ready')
werwolf_server = await(bot.fetch_guild('696079221684175001'))
print(f'members: {[member.name for member in await(werwolf_server.fetch_members().flatten())]}')
@bot.event
async def on_member_join(member):
print(f'{member} has joined a server')
@bot.event
async def on_member_remove(member):
print(f'{member} has left a server')
@bot.command()
async def echo(ctx, *, args):
await ctx.send(args)
@bot.command()
async def ping(ctx):
await ctx.send('pong')
@bot.command()
async def clear(ctx, amount=2):
await ctx.channel.purge(limit=amount)
bot.run('Njk2MTEyNTQ1MDgxMDY1NTU0.Xoj_iQ.VXMY9AUo56o_k-QgLSUWtPldhjE')
client = commands.Bot(command_prefix='$')
client.load_extension('cogs.werewolf')
client.load_extension('cogs.utility_commands')
client.run('Njk2MTEyNTQ1MDgxMDY1NTU0.Xoj_iQ.VXMY9AUo56o_k-QgLSUWtPldhjE')
\ No newline at end of file
def start_game(players):
werwolf_players = [WerwolfPlayer(player.id) for player in players]
class WerwolfPlayer:
def __init__(self, id)
self.id = id
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment