lytescript
v0.0.3
Published
A powerful TypeScript library to create Revolt bots with ease.
Downloads
73
Maintainers
Readme
const { Bot } = require('lytescript')
const client = new Bot({
database?: DatabaseOptions,
events?: string[],
prefixes: string[]
})
const bot = new Bot({...})
bot.commands.add({
name: 'ping',
type: 'message',
code: `
@sendMessage[
@setContent[Pong! <#AT#@author[id]>]
]
`
})
const bot = new Bot({...})
bot.commands.load('./commands_path/').then(async () => {
console.log('Commands loaded')
await bot.login('<TOKEN>', 'bot')
})
/** @type {import('lytescript').ICommand} */
module.exports['default'] = {
name: 'ping',
type: 'message',
code: `
@sendMessage[
@setContent[Pong! <#AT#@author[id]>]
]
`
} // <- This can be an array too.
const bot = new Bot({
events: [
'message',
'ready'
],
prefixes: ['!']
})
bot.commands.add({
name: 'ping',
type: 'message',
code: `
@sendMessage[
@setContent[Pong! <#AT#@author[id]>]
]
`
}).add({
type: 'ready',
code: `
@log[Client started: Name => @client[name]]
`
})
const { Bot } = require('lytescript')
const bot = new Bot({
database: {
path: './mydb',
tables: ['main']
},
events: ['ready'],
prefixes: ['!']
})
bot.commands.add({
type: 'ready',
code: `
@setVar[msg;Hello world!]
@log[@getVar[msg]] // Hello world!
`
})
const bot = new Bot({...})
bot.functions.add({
name: 'multipleSum',
description: 'Sum multiple numbers.',
parameters: [
{
name: 'Numbers',
description: 'Numbers to sum.',
type: ParameterType.Number,
required: true
}
],
execute: async (d) => {
const numbers = d.function.compiled.parameters.map(param => Number(param.value))
let result = 0
for (const nm of numbers)
result = result + nm
return result
}
})