0.1.2-alpha • Published 3 years ago

qope v0.1.2-alpha

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Qope

A simple, innovative and lightweight TS-dedicated library to interact with Discord. Created by Aidak#0001.

In development

Examples

Your main file (index.ts)

import Qope from 'qope'
import * as path from 'path'

const client = new Qope('TOKEN', 'PREFIX')

client.start()

Using normal commands

Your main file (index.ts)

client.registerCommands(path.join(__dirname + '/commands/'))

Example command (commands/example.ts)

export default {
    run: async (qope: any, client: any, ctx: any, options: any) => {
        ctx.sendMessage('Hey, this is a normal command made with Qope!')
    }
}

Using Slash Commands

Your main file (index.ts)

client.configureInteractionConstant({
    applicationID: 'APPLICATION_ID',
    publicKey: 'PUBLIC_KEY'
})
client.registerSlashCommands(path.join(__dirname + '/slash/'))

Example command (slash/example.ts)

export default {
    slashInfo: {
        type: 'GUILD_ONLY', // for global = 'GLOBAL'
        guildID: 'GUILD_ID_HERE', // if the command is global, don't use this parameter
        description: 'DESCRIPTION_HERE',
        options: []
    },
    run: async (qope: any, client: any, ctx: any, options: any) => {
        ctx.sendReply('Hey, this is an example!')
    }
}

Using Message Components

Your main file (index.ts)

client.configureInteractionConstant({
    applicationID: 'APPLICATION_ID',
    publicKey: 'PUBLIC_KEY'
})
client.registerActionRows(path.join(__dirname + '/buttons/'))

Registering the component (buttons/test.ts)

import { Button, ActionRow } from 'qope'

const x: Button = new Button({
    style: 1,
    label: 'Test',
    id: 'test_button',
    run: async (qope, client, interaction) => {
        interaction.interactionDefer(false)
        interaction.sendMessage(`Hello, this a test and your name is: ${interaction.getUser().username}`)
    }
})

export default {
    buttons: new ActionRow([x])
}

Sending the Action Row (slash commands) (slash/buttonexample.ts)

export default {
    slashInfo: {
        type: 'GUILD_ONLY', // for global = 'GLOBAL'
        guildID: 'GUILD_ID_HERE', // if the command is global, don't use this parameter
        description: 'DESCRIPTION_HERE',
        options: []
    },
    run: async (qope: any, client: any, ctx: any, options: any) => {
        ctx.sendMessageAndComponents('Hello, here you have your buttons:', [qope.getActionRow('test')])
    }
}

Sending the Action Row (normal commands) (commands/buttonexample.ts)

export default {
    run: async (qope: any, client: any, ctx: any, options: any) => {
        ctx.sendMessageAndComponents('Hello, here you have your buttons:', [qope.getActionRow('test')])
    }
}