code
parent
813272caef
commit
54d0aa98e3
File diff suppressed because it is too large
Load Diff
@ -1,39 +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?
|
|
||||||
welcome_on Boolean @default(false)
|
|
||||||
users User[]
|
|
||||||
dailymessages DailyMessage[]
|
|
||||||
}
|
|
||||||
|
|
||||||
model DailyMessage {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
text String
|
|
||||||
guild GuildConfig @relation(fields: [guild_id], references: [id])
|
|
||||||
guild_id String
|
|
||||||
hour Int
|
|
||||||
minute Int
|
|
||||||
channel String
|
|
||||||
}
|
|
||||||
|
|
||||||
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}`
|
||||||
|
}
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
import { PrismaClient } from '@prisma/client'
|
|
||||||
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
|
||||||
|
|
||||||
export default class DailyCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'daily',
|
|
||||||
description: 'send daily message',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'hour',
|
|
||||||
description: 'the hour to send the daily message IN UTC!!',
|
|
||||||
type: CommandOptionType.INTEGER,
|
|
||||||
min_value: 0,
|
|
||||||
max_value: 24,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'minute',
|
|
||||||
description: 'the minute to send the daily message IN UTC!!',
|
|
||||||
type: CommandOptionType.INTEGER,
|
|
||||||
min_value: 0,
|
|
||||||
max_value: 59,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'message',
|
|
||||||
description: 'the message to send',
|
|
||||||
type: CommandOptionType.STRING,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
const p = new PrismaClient()
|
|
||||||
await p.dailyMessage.create({
|
|
||||||
data: {
|
|
||||||
hour: ctx.options.hour,
|
|
||||||
minute: ctx.options.minute,
|
|
||||||
text: ctx.options.message,
|
|
||||||
channel: ctx.channelID,
|
|
||||||
guild_id: ctx.guildID
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return `done!`
|
|
||||||
}
|
|
||||||
}
|
|
@ -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,25 +0,0 @@
|
|||||||
import { PrismaClient } from '@prisma/client'
|
|
||||||
import { SlashCommand, SlashCreator, CommandContext } from 'slash-create'
|
|
||||||
|
|
||||||
export default class LeaderboardCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'leaderboard',
|
|
||||||
description: 'see top 10 messages'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
st += `<@${u.id}> - ${u.messages} message(s)\n`
|
|
||||||
}
|
|
||||||
ctx.send(st, {allowedMentions: {everyone: false, roles: false, users: false}})
|
|
||||||
}
|
|
||||||
}
|
|
@ -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)`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import { PrismaClient } from '@prisma/client'
|
|
||||||
import { ChannelType, CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
|
||||||
|
|
||||||
export default class SetWelcomeChannelCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'set_welcome_channel',
|
|
||||||
description: 'setwelcomechannel',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'channel',
|
|
||||||
description: 'channel - blank to see current',
|
|
||||||
type: CommandOptionType.CHANNEL,
|
|
||||||
channel_types: [ChannelType.GUILD_TEXT]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
const prisma = new PrismaClient()
|
|
||||||
if (ctx.options.channel == null) {
|
|
||||||
const gc = await prisma.guildConfig.findFirst({
|
|
||||||
where: {
|
|
||||||
id: ctx.guildID
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return `current welcomechannel is ${
|
|
||||||
'<#' + gc.welcome_channel + '>' ?? 'none (use /set_welcome_channel #CHANNEL)'
|
|
||||||
}`
|
|
||||||
}
|
|
||||||
await prisma.guildConfig.update({
|
|
||||||
where: {
|
|
||||||
id: ctx.guildID
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
welcome_channel: ctx.options.channel
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return `set the welcomechannel to <#${ctx.options.channel}>`
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
import { PrismaClient } from '@prisma/client'
|
|
||||||
import { CommandContext, SlashCommand, SlashCreator, CommandOptionType } from 'slash-create'
|
|
||||||
|
|
||||||
export default class SetWelcomeMessageCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'setwelcomemessage',
|
|
||||||
description: 'set the welcome message, %USER% replaces to a mention of the joined user',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'message',
|
|
||||||
description: 'the message (leave blank to see current message)',
|
|
||||||
type: CommandOptionType.STRING
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
const prisma = new PrismaClient()
|
|
||||||
if (ctx.options.message == null) {
|
|
||||||
const g = await prisma.guildConfig.findFirst({ where: { id: ctx.guildID } })
|
|
||||||
return `the current welcome message is ${g.welcome_message}`
|
|
||||||
}
|
|
||||||
|
|
||||||
await prisma.guildConfig.update({ where: { id: ctx.guildID }, data: { welcome_message: ctx.options.message } })
|
|
||||||
return `updated your welcome message to ${ctx.options.message}!`
|
|
||||||
}
|
|
||||||
}
|
|
@ -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=${process.env.ALPHAVANTAGE_KEY}`)
|
|
||||||
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']}`
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create';
|
|
||||||
|
|
||||||
export default class ToggleWelcomerCommand extends SlashCommand {
|
|
||||||
constructor(creator: SlashCreator) {
|
|
||||||
super(creator, {
|
|
||||||
name: 'toggle_welcomer',
|
|
||||||
description: 'toggle the welcome',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'setting',
|
|
||||||
type: CommandOptionType.BOOLEAN,
|
|
||||||
description: 'whether it is on or not (leave blank to see the current setting)'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(ctx: CommandContext) {
|
|
||||||
const p = new PrismaClient()
|
|
||||||
if (ctx.options.setting == null) {
|
|
||||||
const gcf = await p.guildConfig.findFirst({
|
|
||||||
where: {
|
|
||||||
id: ctx.guildID
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return `the welcomer is currently ${gcf.welcome_on ? 'on' : 'off'}`
|
|
||||||
}
|
|
||||||
|
|
||||||
await p.guildConfig.update({
|
|
||||||
where: {
|
|
||||||
id: ctx.guildID
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
welcome_on: ctx.options.setting
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return `set welcomer to ${ctx.options.setting ? 'on' : 'off'}`
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue