Message Blocks for Normal Message Style (#37)
* add: if check for message length * update: version increment * update: readme
This commit is contained in:
@@ -15,7 +15,7 @@ The project aims to:
|
|||||||
* [ ] Message Persistance on Channels and Threads
|
* [ ] Message Persistance on Channels and Threads
|
||||||
* [x] Containerization with Docker
|
* [x] Containerization with Docker
|
||||||
* [x] Slash Commands Compatible
|
* [x] Slash Commands Compatible
|
||||||
* [ ] Generated Token Length Handling for >2000 or >6000 characters
|
* [x] Generated Token Length Handling for >2000 ~~or >6000 characters~~
|
||||||
* [ ] External WebUI Integration
|
* [ ] External WebUI Integration
|
||||||
* [ ] Administrator Role Compatible
|
* [ ] Administrator Role Compatible
|
||||||
* [ ] Allow others to create their own models personalized for their own servers!
|
* [ ] Allow others to create their own models personalized for their own servers!
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ services:
|
|||||||
build: ./ # find docker file in designated path
|
build: ./ # find docker file in designated path
|
||||||
container_name: discord
|
container_name: discord
|
||||||
restart: always # rebuild container always
|
restart: always # rebuild container always
|
||||||
image: discord/bot:0.3.6
|
image: discord/bot:0.4.0
|
||||||
environment:
|
environment:
|
||||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||||
GUILD_ID: ${GUILD_ID}
|
GUILD_ID: ${GUILD_ID}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.3.6",
|
"version": "0.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.3.6",
|
"version": "0.4.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-ollama",
|
"name": "discord-ollama",
|
||||||
"version": "0.3.6",
|
"version": "0.4.0",
|
||||||
"description": "Ollama Integration into discord",
|
"description": "Ollama Integration into discord",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"exports": "./build/index.js",
|
"exports": "./build/index.js",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export async function normalMessage(
|
|||||||
// bot's respnse
|
// bot's respnse
|
||||||
let response: ChatResponse
|
let response: ChatResponse
|
||||||
|
|
||||||
await message.reply('Generating Response . . .').then(async sentMessage => {
|
await message.channel.send('Generating Response . . .').then(async sentMessage => {
|
||||||
try {
|
try {
|
||||||
// Attempt to query model for message
|
// Attempt to query model for message
|
||||||
response = await ollama.chat({
|
response = await ollama.chat({
|
||||||
@@ -36,8 +36,12 @@ export async function normalMessage(
|
|||||||
stream: false
|
stream: false
|
||||||
})
|
})
|
||||||
|
|
||||||
// edit the 'generic' response to new message
|
// check if message length > discord max for normal messages
|
||||||
sentMessage.edit(response.message.content)
|
if (response.message.content.length > 2000) {
|
||||||
|
sentMessage.edit(response.message.content.slice(0, 2000))
|
||||||
|
message.channel.send(response.message.content.slice(2000))
|
||||||
|
} else // edit the 'generic' response to new message
|
||||||
|
sentMessage.edit(response.message.content)
|
||||||
} catch(error: any) {
|
} catch(error: any) {
|
||||||
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
|
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
|
||||||
sentMessage.edit(`**Response generation failed.**\n\nReason: ${error.message}`)
|
sentMessage.edit(`**Response generation failed.**\n\nReason: ${error.message}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user