Compare commits
No commits in common. '54d0aa98e32db403bee372cb03f45f01ecc51371' and '55d8df5f28a9ee95daa12c21ce7695ca43b2bfa4' have entirely different histories.
54d0aa98e3
...
55d8df5f28
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,30 @@
|
|||||||
|
// This is your Prisma schema file,
|
||||||
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "postgresql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
model GuildConfig {
|
||||||
|
id String @id
|
||||||
|
welcome_message String @default("Hello %USER%!")
|
||||||
|
welcome_channel String?
|
||||||
|
daily_message_text String @default("daily message")
|
||||||
|
daily_message_channel String?
|
||||||
|
daily_message_time DateTime @default(now()) @db.Timetz
|
||||||
|
users User[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model User {
|
||||||
|
id String
|
||||||
|
guild GuildConfig @relation(fields: [guild_id], references: [id])
|
||||||
|
guild_id String
|
||||||
|
messages Int @default(0)
|
||||||
|
|
||||||
|
@@id([id, guild_id])
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
import { SlashCommand, SlashCreator, CommandContext, CommandOptionType } from 'slash-create';
|
|
||||||
import { Client } from 'discord.js'
|
|
||||||
const valid = ['498992803532242945', '435206857276260353']
|
|
||||||
|
|
||||||
export default class PingCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'andrewkuo',
|
|
||||||
description: 'give andrewkuo role',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'who',
|
|
||||||
description: 'who',
|
|
||||||
type: CommandOptionType.USER,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
if (valid.indexOf(ctx.user.id) == -1) {
|
|
||||||
return 'no'
|
|
||||||
}
|
|
||||||
const cli = this.client as Client
|
|
||||||
const g = cli.guilds.cache.get(ctx.guildID)
|
|
||||||
const me = g.members.cache.get(ctx.options.who as string)
|
|
||||||
await me.roles.add('1148804439755460638', '/andrewkuo')
|
|
||||||
return `gave andrewkuo role to @${me.user.username}`
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
|
||||||
|
|
||||||
const things: Record<string, string> = {
|
|
||||||
'gm': 'good morning',
|
|
||||||
'ga': 'good afternoon',
|
|
||||||
'gn': 'good night'
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class RPSCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'g',
|
|
||||||
description: 'gmgnga',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'type',
|
|
||||||
description: 'type of gmgnga',
|
|
||||||
type: CommandOptionType.STRING,
|
|
||||||
choices: [
|
|
||||||
{ name: 'gm', value: 'gm' },
|
|
||||||
{ name: 'ga', value: 'ga' },
|
|
||||||
{ name: 'gn', value: 'gn' }
|
|
||||||
],
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'who',
|
|
||||||
description: 'who to gmgnga (optional)',
|
|
||||||
type: CommandOptionType.USER,
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
if (ctx.options.who == null) {
|
|
||||||
return `<@${ctx.member?.id}> says ${things[ctx.options.type as 'gm' | 'gn' | 'ga']}`
|
|
||||||
} else {
|
|
||||||
return `<@${ctx.member?.id}> says ${things[ctx.options.type as 'gm' | 'gn' | 'ga']} to <@${ctx.options.who}>`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
import { SlashCommand, SlashCreator, CommandContext, MessageEmbed } from 'slash-create'
|
||||||
|
|
||||||
|
export default class LeaderboardCommand extends SlashCommand {
|
||||||
|
constructor(creator: SlashCreator) {
|
||||||
|
super(creator, {
|
||||||
|
name: 'leaderboard',
|
||||||
|
description: 'see top 10 messages'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
async run(ctx: CommandContext) {
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
const users = await prisma.user.findMany({
|
||||||
|
where: { guild_id: ctx.guildID },
|
||||||
|
take: 10,
|
||||||
|
orderBy: { messages: 'desc' }
|
||||||
|
})
|
||||||
|
let st = ''
|
||||||
|
for (const u of users) {
|
||||||
|
const uu = await this.client.users.fetch(u.id)
|
||||||
|
st += `${uu.username}#${uu.discriminator} - ${u.messages} message(s)\n`
|
||||||
|
}
|
||||||
|
return st
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
export default class MessagesCommand extends SlashCommand {
|
||||||
|
constructor(creator: SlashCreator) {
|
||||||
|
super(creator, {
|
||||||
|
name: 'messages',
|
||||||
|
description: 'show message count, either for yourself, or someone else',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'user',
|
||||||
|
description: 'person to show messages for (blank shows your own)',
|
||||||
|
required: false,
|
||||||
|
type: CommandOptionType.USER
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(ctx: CommandContext) {
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
if (ctx.options.user == null) {
|
||||||
|
const u = await prisma.user.findFirst({ where: { id: ctx.member?.id, guild: { id: ctx.guildID } } })
|
||||||
|
if (!u) return `you have no messages!`
|
||||||
|
return `you have ${u.messages} message(s)`
|
||||||
|
} else {
|
||||||
|
const uid = ctx.options.user
|
||||||
|
const u = await prisma.user.findFirst({ where: { id: uid, guild: { id: ctx.guildID } } })
|
||||||
|
if (!u) return `this user has no messages!`
|
||||||
|
const uu = await this.client.users.fetch(u.id)
|
||||||
|
return `${uu.username}#${uu.discriminator} has ${u.messages} message(s)`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +0,0 @@
|
|||||||
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
|
||||||
|
|
||||||
export default class RPSCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'rps',
|
|
||||||
description: 'play rock paper scissors',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'choice',
|
|
||||||
description: 'what you want to play',
|
|
||||||
type: CommandOptionType.STRING,
|
|
||||||
choices: [
|
|
||||||
{ name: 'rock', value: 'rock' },
|
|
||||||
{ name: 'paper', value: 'paper' },
|
|
||||||
{ name: 'scissors', value: 'scissors' }
|
|
||||||
],
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
const uc = ctx.options.choice
|
|
||||||
const cc = ['rock', 'paper', 'scissors'][Math.floor(Math.random() * 3)]
|
|
||||||
let winner = ''
|
|
||||||
if (uc == cc) {
|
|
||||||
winner = "it's a tie!"
|
|
||||||
} else if (
|
|
||||||
(uc == 'rock' && cc == 'scissors') ||
|
|
||||||
(uc == 'paper' && cc == 'rock') ||
|
|
||||||
(uc == 'scissors' && cc == 'paper')
|
|
||||||
) {
|
|
||||||
winner = 'you win!'
|
|
||||||
} else {
|
|
||||||
winner = 'computer wins!'
|
|
||||||
}
|
|
||||||
return `you chose ${uc} and the computer chose ${cc}. ${winner}`
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,23 @@
|
|||||||
|
/* eslint-disable prettier/prettier */
|
||||||
|
import { SlashCommand, SlashCreator, CommandOptionType, CommandContext } from 'slash-create';
|
||||||
|
|
||||||
|
export default class StockCommand extends SlashCommand {
|
||||||
|
constructor(creator: SlashCreator) {
|
||||||
|
super(creator, {
|
||||||
|
name: 'stock',
|
||||||
|
description: 'checks stock price',
|
||||||
|
options: [{ type: CommandOptionType.STRING, name: 'ticker', description: 'the ticker to check', required: true }]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(ctx: CommandContext) {
|
||||||
|
const tkr = ctx.options.ticker
|
||||||
|
const req = await fetch(`https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${tkr}&apikey=8O1INVBY11E0GRGC`)
|
||||||
|
const info = await req.json()
|
||||||
|
if (Object.keys(info['Global Quote']).length == 0) {
|
||||||
|
return `stock not found!`
|
||||||
|
}
|
||||||
|
const i = info['Global Quote']
|
||||||
|
return `stock info for ${i['01. symbol']} - OPEN: ${i['02. open']} - PRICE: ${i['05. price']} - % CHANGE: ${i['10. change percent']}`
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue