This commit is contained in:
Nikolaj Danger
2020-08-06 13:07:19 +02:00
parent cab088af3d
commit b894480446
2 changed files with 41 additions and 95 deletions

View File

@ -1,54 +1,52 @@
# -*- coding: utf-8 -*-
import discord
import asyncio
#import pickle
import codecs
import string
import json
import random
#import math
import os
import discord, os
from discord.ext import commands
from funcs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, emojiToCommand, fiarReactionTest, deleteGame, stopServer, checkBalance, giveMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, spellFunc, monsterFunc, nameGen, tavernGen, movieFunc, roll_dice, parseChar, parseRoll, critRoll, parseDestiny, parseHex, addToDict, monopolyReactionTest
from funcs import logThis, makeFiles
from gameLoops import fiar, blackjackLoop, runHex, runMonopoly
commandPrefix = "!"
client = commands.Bot(command_prefix=commandPrefix)
# Blackjack shuffle variables
blackjackMinCards = 50
blackjackDecks = 4
# Logs in
@client.event
async def on_ready():
logThis("Logged in as "+client.user.name+", "+str(client.user.id))
game = discord.Game("Some weeb shit")
await client.change_presence(activity=game)
async def parseCommands(message,content):
# Loads and unloads cogs
# Runs a game of four in a row
elif content.startswith("fourinarow"):
try:
command = content.replace("fourinarow","")
await fiar(message.channel,command,"#"+str(message.author.id))
except:
logThis("Something went wrong (error code 1400)")
@client.command()
async def load(ctx,extension):
client.load_extension(f"cogs.{extension}")
# Runs a game of Hex
elif content.startswith("hex"):
try:
command = content.replace("hex","")
await runHex(message.channel,command,"#"+str(message.author.id))
except:
logThis("Something went wrong (error code 1500)")
# Runs a game of monopoly
elif content.startswith("monopoly"):
try:
command = content.replace("monopoly","",1)
await runMonopoly(message.channel,command,"#"+str(message.author.id))
except:
logThis("Something went wrong (error code 1600)")
# Not a command
@client.command()
async def unload(ctx,extension):
client.unload_extension(f"cogs.{extension}")
@client.event
async def on_command(ctx):
logThis(f"{ctx.message.author.display_name} ran {ctx.message.content}")
# Logs if a command experiences an error
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("That's not a command (error code 001)")
else:
logThis("That's not a command (error code 001)",str(message.channel.id))
await message.channel.send("That's not a command (error code 001)")
logThis(f"Something went wrong, {error}",str(ctx.message.channel.id))
await ctx.send("Something went wrong (error code 000)")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")
# Creates the required files
makeFiles()
# Gets secret bot token
with open("token.txt","r") as f:
token = f.read().replace("\n","")
# Runs the whole shabang
client.run(token)

52
bot.py
View File

@ -1,52 +0,0 @@
import discord, os
from discord.ext import commands
from funcs import logThis, makeFiles
commandPrefix = "!"
client = commands.Bot(command_prefix=commandPrefix)
# Logs in
@client.event
async def on_ready():
logThis("Logged in as "+client.user.name+", "+str(client.user.id))
game = discord.Game("Some weeb shit")
await client.change_presence(activity=game)
# Loads and unloads cogs
@client.command()
async def load(ctx,extension):
client.load_extension(f"cogs.{extension}")
@client.command()
async def unload(ctx,extension):
client.unload_extension(f"cogs.{extension}")
@client.event
async def on_command(ctx):
logThis(f"{ctx.message.author.display_name} ran {ctx.message.content}")
# Logs if a command experiences an error
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("That's not a command (error code 001)")
else:
logThis(f"Something went wrong, {error}",str(ctx.message.channel.id))
await ctx.send("Something went wrong (error code 000)")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")
# Creates the required files
makeFiles()
# Gets secret bot token
with open("token.txt","r") as f:
token = f.read().replace("\n","")
# Runs the whole shabang
client.run(token)