Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit 8a4e212

Browse files
committed
first commit
0 parents  commit 8a4e212

File tree

15 files changed

+510
-0
lines changed

15 files changed

+510
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
schedule:
10+
- cron: '42 16 * * *'
11+
push:
12+
branches: [main]
13+
# Publish semver tags as releases.
14+
tags: ['v*.*.*']
15+
16+
env:
17+
# Use docker.io for Docker Hub if empty
18+
REGISTRY: ghcr.io
19+
# github.repository as <account>/<repo>
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
32+
33+
# Login against a Docker registry except on PR
34+
# https://github.com/docker/login-action
35+
- name: Log into registry ${{ env.REGISTRY }}
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
# Extract metadata (tags, labels) for Docker
44+
# https://github.com/docker/metadata-action
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
51+
# Build and push Docker image with Buildx (don't push on PR)
52+
# https://github.com/docker/build-push-action
53+
- name: Build and push Docker image
54+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
55+
with:
56+
context: .
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ENV
2+
*.env
3+
!example.env
4+
5+
# Typescript
6+
dist/
7+
8+
# NodeJS
9+
node_modules/
10+
package-lock.json
11+
12+
#IntelliJ
13+
.idea/
14+
15+
# Prisma
16+
prisma/*
17+
!prisma/schema.prisma

.prettierrc.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
useTabs = true
2+
singleQuote = true
3+
jsxSingleQuote = true
4+
jsxBracketSameLine = true
5+
trailingComma = "none"
6+
semi = true
7+
printWidth = 100

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:18.7.0
2+
3+
# Run program in production
4+
ENV NODE_ENV=production
5+
6+
# Set working directory and add source files
7+
WORKDIR /app
8+
COPY . .
9+
10+
# Install dependencies, then run the program
11+
RUN npm install --production
12+
RUN npm run migrate
13+
ENTRYPOINT [ "npm", "start" ]

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Lilian
2+
3+
This is a bot that brings pronouns.page into Discord!
4+
5+
## Invite the bot
6+
7+
You can invite the bot [here](https://bit.ly/3I3IWnN), top.gg link will come soon.
8+
9+
## Running the bot
10+
11+
If you don't want to use the hosted version, you can run your own instance pretty simply.
12+
13+
### Create a volume
14+
15+
Lilain uses SQLite for data storage, so a volume is needed in order to use it with Docker.
16+
17+
```bash
18+
docker volume create lilian
19+
```
20+
21+
### Run the container
22+
23+
```bash
24+
# Pull the docker image
25+
docker pull ghcr.io/astridlol/lilian:main
26+
27+
# Run a container with the image
28+
docker run --name lilian -e TOKEN=[your token] -v lilian:/app -d --restart always ghcr.io/astridlol/lilian:main
29+
```

example.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TOKEN=

package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "lilian",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"type": "commonjs",
7+
"scripts": {
8+
"start": "node .",
9+
"prestart": "tsc --p tsconfig.json",
10+
"format": "prettier --write ./",
11+
"dev": "npm run format && ts-node src/index.ts",
12+
"migrate": "npx prisma migrate dev --name init"
13+
},
14+
"keywords": [],
15+
"author": "Astrid",
16+
"license": "ISC",
17+
"devDependencies": {
18+
"prettier": "^2.7.1",
19+
"prisma": "^4.10.1"
20+
},
21+
"dependencies": {
22+
"@discordx/importer": "^1.1.10",
23+
"@prisma/client": "^4.10.1",
24+
"@types/node": "^18.6.1",
25+
"@types/node-fetch": "^2.6.2",
26+
"axios": "^1.3.3",
27+
"discord.js": "^14.2.0",
28+
"discordx": "^11.1.9",
29+
"dotenv": "^16.0.1",
30+
"node-cache": "^5.1.2",
31+
"node-fetch": "^2.6.7",
32+
"pusher": "^5.1.3",
33+
"random-word": "^2.0.0",
34+
"reflect-metadata": "^0.1.13",
35+
"ts-node": "^10.9.1",
36+
"typescript": "^4.7.4"
37+
}
38+
}

prisma/schema.prisma

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This is your Prisma schema file,
2+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3+
4+
generator client {
5+
provider = "prisma-client-js"
6+
binaryTargets = ["native"]
7+
}
8+
9+
datasource db {
10+
provider = "sqlite"
11+
url = "file:dev.db"
12+
}
13+
14+
model Sessions {
15+
id String @id @default(cuid())
16+
}
17+
18+
model Server {
19+
// Guild ID
20+
id String @id
21+
// API Key
22+
apiKey String?
23+
}

src/commands/link.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { ApplicationCommandOptionType, CommandInteraction } from 'discord.js';
2+
import { Discord, Slash, SlashOption } from 'discordx';
3+
import { prisma, pusher } from '..';
4+
5+
@Discord()
6+
class LinkCommand {
7+
@Slash({ description: 'Link your Minecraft account' })
8+
async link(
9+
@SlashOption({
10+
description: "What's your Minecraft IGN?",
11+
name: 'ign',
12+
required: true,
13+
type: ApplicationCommandOptionType.String
14+
})
15+
username: string,
16+
interaction: CommandInteraction
17+
) {
18+
19+
// Arozeeeee make these messages pretty, ty 💜
20+
21+
await interaction.deferReply({
22+
ephemeral: true
23+
});
24+
25+
const server = await prisma.server.findFirst({
26+
where: {
27+
id: interaction.guildId
28+
}
29+
});
30+
31+
if (!server.apiKey) {
32+
interaction.editReply({
33+
content: `This server hasn't setup Linky properly. Contact a server admin`
34+
});
35+
return;
36+
}
37+
38+
pusher.trigger(server.apiKey, 'link-request', {
39+
username,
40+
discordName: interaction.user.username
41+
});
42+
43+
interaction.editReply({
44+
content: 'Check in game for a approval request.'
45+
});
46+
}
47+
}

src/commands/settings.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ApplicationCommandOptionType, CommandInteraction } from 'discord.js';
2+
import { Discord, Guard, Slash, SlashGroup, SlashOption } from 'discordx';
3+
import { RequirePermission } from '../guards/RequirePermission';
4+
import { prisma } from '..';
5+
6+
@Discord()
7+
@Guard(RequirePermission('ManageGuild'))
8+
@SlashGroup({
9+
description: 'Manage Linky settings',
10+
name: 'settings'
11+
})
12+
@SlashGroup('settings')
13+
class SettingsCommand {
14+
@Slash({ description: 'Set your servers API key' })
15+
async apikey(
16+
@SlashOption({
17+
description: 'Server API Key',
18+
name: 'key',
19+
required: true,
20+
type: ApplicationCommandOptionType.String
21+
})
22+
key: string,
23+
interaction: CommandInteraction
24+
) {
25+
await interaction.deferReply({
26+
ephemeral: true
27+
});
28+
29+
await prisma.server.update({
30+
where: {
31+
id: interaction.guildId
32+
},
33+
data: {
34+
apiKey: key
35+
}
36+
});
37+
38+
interaction.editReply({
39+
content: 'Successfully set the servers API key.'
40+
});
41+
}
42+
}

0 commit comments

Comments
 (0)