Skip to content

Commit

Permalink
update all discord templates and handlers, update bot config file
Browse files Browse the repository at this point in the history
  • Loading branch information
david-tomson committed May 9, 2022
1 parent f541955 commit b339b8b
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 609 deletions.
Empty file added docker/full.dockerfile
Empty file.
4 changes: 2 additions & 2 deletions internal/pipes/new/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func buildBot(msg tea.Msg, m model, botName string) (tea.Model, tea.Cmd) {
viper.SetDefault("bot.version", "0.1.0")
dockerImage := conf.String("user.docker_id") + "/" + opts.BotName
viper.SetDefault("docker.image", dockerImage)
viper.SetDefault("docker.build_cmd", "docker build -t " + dockerImage + " .")
viper.SetDefault("docker.run_cmd", "docker run -it " + dockerImage)
viper.SetDefault("docker.cmds.build", "docker build -t " + dockerImage + " .")
viper.SetDefault("docker.cmds.run", "docker run -it " + dockerImage)

if err := viper.SafeWriteConfig(); err != nil {
if os.IsNotExist(err) {
Expand Down
17 changes: 7 additions & 10 deletions internal/pipes/new/discord_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package new
import (
"github.com/abdfnx/botway/templates/discord/deno"
"github.com/abdfnx/botway/templates/discord/go"
"github.com/abdfnx/botway/templates/discord/nodejs/npm"
"github.com/abdfnx/botway/templates/discord/nodejs/pnpm"
"github.com/abdfnx/botway/templates/discord/nodejs/yarn"
"github.com/abdfnx/botway/templates/discord/nodejs"
"github.com/abdfnx/botway/templates/discord/python/pip"
"github.com/abdfnx/botway/templates/discord/python/pipenv"
"github.com/abdfnx/botway/templates/discord/ruby"
"github.com/abdfnx/botway/templates/discord/rust/cargo"
"github.com/abdfnx/botway/templates/discord/rust/fleet"
"github.com/abdfnx/botway/templates/discord/rust"
)

func DiscordHandler(m model) {
Expand All @@ -21,17 +18,17 @@ func DiscordHandler(m model) {
} else if m.PlatformChoice == 0 && m.LangChoice == 1 {
dgo.DiscordGo(opts.BotName)
} else if m.PlatformChoice == 0 && m.LangChoice == 2 && m.PMCoice == 0 {
npm.DiscordNodejsNpm(opts.BotName)
nodejs.DiscordNodejs(opts.BotName, "npm")
} else if m.PlatformChoice == 0 && m.LangChoice == 2 && m.PMCoice == 1 {
yarn.DiscordNodejsYarn(opts.BotName)
nodejs.DiscordNodejs(opts.BotName, "yarn")
} else if m.PlatformChoice == 0 && m.LangChoice == 2 && m.PMCoice == 2 {
pnpm.DiscordNodejsPnpm(opts.BotName)
nodejs.DiscordNodejs(opts.BotName, "pnpm")
} else if m.PlatformChoice == 0 && m.LangChoice == 3 {
ruby.DiscordRuby(opts.BotName)
} else if m.PlatformChoice == 0 && m.LangChoice == 4 && m.PMCoice == 0 {
cargo.DiscordRustCargo(opts.BotName)
rust.DiscordRust(opts.BotName, "cargo")
} else if m.PlatformChoice == 0 && m.LangChoice == 4 && m.PMCoice == 1 {
fleet.DiscordRustFleet(opts.BotName)
rust.DiscordRust(opts.BotName, "fleet")
} else if m.PlatformChoice == 0 && m.LangChoice == 5 {
deno.DiscordDeno(opts.BotName)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pipes/new/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func BotStartCmd(m model) string {
} else if m.LangChoice == 1 {
return "go run src/main.go"
} else if m.LangChoice == 2 {
return "node src/main.js"
return "node src/index.js"
} else if m.LangChoice == 3 {
return "bundle exec ruby src/main.rb"
} else if m.LangChoice == 4 {
Expand Down
8 changes: 4 additions & 4 deletions templates/discord/deno/assets/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM alpine:latest
FROM node:alpine
FROM denoland/deno:alpine
FROM botwayorg/botway:latest

ENV DISCORD_BOT_NAME="{{.BotName}}"
ARG DISCORD_TOKEN
ARG DISCORD_CLIENT_ID
# Uncomment the comment below to add your guild id, like this syntax --> ARG MY_SERVER_GUILD_ID
# ARG SERVER_GUILD_ID

ADD . .

Expand All @@ -15,12 +15,12 @@ RUN apk update && \
# Add packages you want
# RUN apk add PACKAGE_NAME

RUN botway init --docker --name ${DISCORD_BOT_NAME}
RUN botway init --docker

USER deno

RUN deno cache deps.ts

EXPOSE 8000

ENTRYPOINT ["deno", "run", "--allow-net", "--allow-write", "--allow-read", "--allow-run", "mod.ts"]
ENTRYPOINT ["deno", "run", "--allow-all", "mod.ts"]
2 changes: 1 addition & 1 deletion templates/discord/deno/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func DiscordDeno(botName string) {
utilsHelpersTsFile := os.WriteFile(filepath.Join(botName, "src", "utils", "helpers.ts"), []byte(UtilsHelpersTsContent()), 0644)
utilsLoggerTsFile := os.WriteFile(filepath.Join(botName, "src", "utils", "logger.ts"), []byte(UtilsLoggerTsContent()), 0644)
dockerFile := os.WriteFile(filepath.Join(botName, "Dockerfile"), []byte(DockerfileContent(botName)), 0644)
procFile := os.WriteFile(filepath.Join(botName, "Procfile"), []byte("process: deno run --allow-net --allow-write --allow-read --allow-run mod.ts"), 0644)
procFile := os.WriteFile(filepath.Join(botName, "Procfile"), []byte("process: deno run --allow-all mod.ts"), 0644)
resourcesFile := os.WriteFile(filepath.Join(botName, "resources.md"), []byte(Resources()), 0644)

if modFile != nil {
Expand Down
4 changes: 3 additions & 1 deletion templates/discord/go/assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ FROM botwayorg/botway:latest
ENV DISCORD_BOT_NAME="{{.BotName}}"
ARG DISCORD_TOKEN
ARG DISCORD_CLIENT_ID
# Uncomment the comment below to add your guild id, like this syntax --> ARG MY_SERVER_GUILD_ID
# ARG SERVER_GUILD_ID

COPY . .

Expand All @@ -14,7 +16,7 @@ RUN apk update && \
# Add packages you want
# RUN apk add PACKAGE_NAME

RUN botway init --docker --name ${DISCORD_BOT_NAME}
RUN botway init --docker
RUN go mod tidy
RUN go build src/main.go -o ${DISCORD_BOT_NAME}

Expand Down
5 changes: 3 additions & 2 deletions templates/discord/nodejs/assets/npm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ FROM node:alpine
FROM botwayorg/botway:latest

ENV NODE_ENV=production
ENV DISCORD_BOT_NAME="{{.BotName}}"
ARG DISCORD_TOKEN
ARG DISCORD_CLIENT_ID
# Uncomment the comment below to add your guild id, like this syntax --> ARG MY_SERVER_GUILD_ID
# ARG SERVER_GUILD_ID

COPY . .

Expand All @@ -15,7 +16,7 @@ RUN apk update && \
# Add packages you want
# RUN apk add PACKAGE_NAME

RUN botway init --docker --name ${DISCORD_BOT_NAME}
RUN botway init --docker
RUN npm i --production

EXPOSE 8000
Expand Down
5 changes: 3 additions & 2 deletions templates/discord/nodejs/assets/pnpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ FROM alpine:latest
FROM node:alpine
FROM botwayorg/botway:latest

ENV DISCORD_BOT_NAME="{{.BotName}}"
ARG DISCORD_TOKEN
ARG DISCORD_CLIENT_ID
# Uncomment the comment below to add your guild id, like this syntax --> ARG MY_SERVER_GUILD_ID
# ARG SERVER_GUILD_ID

RUN apk update && \
apk add --no-cache --virtual build-dependencies build-base gcc git ffmpeg

# Add packages you want
# RUN apk add PACKAGE_NAME

RUN botway init --docker --name ${DISCORD_BOT_NAME}
RUN botway init --docker
RUN curl -fsSL https://get.pnpm.io/install.sh | PNPM_VERSION=7.0.0 sh -

RUN pnpm fetch --prod
Expand Down
3 changes: 2 additions & 1 deletion templates/discord/nodejs/assets/yarn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ FROM alpine:latest
FROM node:alpine
FROM botwayorg/botway:latest

ENV DISCORD_BOT_NAME="{{.BotName}}"
ARG DISCORD_TOKEN
ARG DISCORD_CLIENT_ID
# Uncomment the comment below to add your guild id, like this syntax --> ARG MY_SERVER_GUILD_ID
# ARG SERVER_GUILD_ID

COPY . .

Expand Down
7 changes: 0 additions & 7 deletions templates/discord/nodejs/npm/contents.go

This file was deleted.

116 changes: 0 additions & 116 deletions templates/discord/nodejs/npm/index.go

This file was deleted.

7 changes: 0 additions & 7 deletions templates/discord/nodejs/pnpm/contents.go

This file was deleted.

Loading

0 comments on commit b339b8b

Please sign in to comment.