~riderius/riderius-cogs

b724fe0ef7dac28be6df0bad263242eeab4410b6 — riderius a month ago a62e08c
add newcog.sh for automatically create new cogs

Signed-off-by: riderius <riderius.help@gmail.com>
1 files changed, 37 insertions(+), 0 deletions(-)

A newcog.sh
A newcog.sh => newcog.sh +37 -0
@@ 0,0 1,37 @@
#!/usr/bin/bash

NAME=$1
LOWERCASE_NAME=`echo $1 | tr '[:upper:]' '[:lower:]'`

mkdir $NAME

#__init__.py
echo "from .$LOWERCASE_NAME import $NAME" >> $NAME/__init__.py
echo "" >> $NAME/__init__.py
echo "" >> $NAME/__init__.py
echo "def setup(bot):" >> $NAME/__init__.py
echo "    bot.add_cog($NAME(bot))" >> $NAME/__init__.py

#info.json
echo "{" >> $NAME/info.json
echo "    \"author\" : "[\"riderius\"]", " >> $NAME/info.json
echo "    \"install_msg\" : \"\", " >> $NAME/info.json
echo "    \"name\" : \"$NAME\", " >> $NAME/info.json
echo "    \"short\" : \"\", " >> $NAME/info.json
echo "    \"description\" : \"\", " >> $NAME/info.json
echo "}" >> $NAME/info.json
sed 's/[ \t]\+$//' $NAME/info.json > /tmp/info.json.new
cat /tmp/info.json.new > $NAME/info.json

#LOWERCASE_NAME.py
echo "from redbot.core import commands" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "class $NAME(commands.Cog):" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "    def __init__(self, bot):" >> $NAME/$LOWERCASE_NAME.py
echo "      self.bot = bot" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "  @commands.command()" >> $NAME/$LOWERCASE_NAME.py
echo "  async def $LOWERCASE_NAME(self, ctx):" >> $NAME/$LOWERCASE_NAME.py
echo "      \"\"\"\"\"\"" >> $NAME/$LOWERCASE_NAME.py