Compare commits
10 Commits
55d8df5f28
...
54d0aa98e3
Author | SHA1 | Date |
---|---|---|
|
54d0aa98e3 | 2 years ago |
|
813272caef | 2 years ago |
|
9e2ad127b6 | 2 years ago |
|
c46c1f6c01 | 2 years ago |
|
93f765b88c | 2 years ago |
|
6461b9ca79 | 2 years ago |
|
a52d005be4 | 2 years ago |
|
0ea8a441db | 2 years ago |
|
e1b7f4722f | 2 years ago |
|
6837f27118 | 2 years ago |
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
|||||||
// 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])
|
|
||||||
}
|
|
@ -0,0 +1,31 @@
|
|||||||
|
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}`
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
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}>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
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)`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
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}`
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +0,0 @@
|
|||||||
/* 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