Commands split up into single files and included first methods

This commit is contained in:
s-prechtl 2021-10-22 16:30:47 +02:00
parent 5c2ff27656
commit ef19e6659e
9 changed files with 93 additions and 29 deletions

View file

@ -1,3 +1,4 @@
import pickle
from abc import ABC
import discord
@ -9,14 +10,32 @@ import APICommands.Command
class Prefix(APICommands.Command.Command, ABC):
keywords = ["prefix"]
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords: list):
def __init__(self, pref, api: riotwatcher.LolWatcher, additionalKeywords=None):
if additionalKeywords is None:
additionalKeywords = []
super().__init__(pref, api, additionalKeywords)
self.commandName = "Prefix change"
async def execute(self, message: discord.Message):
pass
if message.content == (self.pref + "prefix"):
await self.info(message)
elif message.content.split(" ").length == 2:
self.log(message)
await self.changePrefix(message)
else:
await self.usage(message)
async def info(self, message: discord.Message):
pass
await message.channel.send(
"Your current prefix is: " + self.pref + ". To change it use " + self.pref + "prefix [new Prefix]")
async def usage(self, message: discord.Message):
pass
await message.channel.send("Wrong usage of prefix command! Use " + self.pref + "prefix [new Prefix (optional)]")
async def changePrefix(self, message: discord.Message):
try:
self.pref = message.content.split(" ")[1]
await message.channel.send("Prefix successfully changed to " + self.pref)
pickle.dump(self.pref, open("prefix.data", "wb"))
except:
await self.usage(message)