Estal
Estal
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
ah; yeah; sometimes it does take more than three seconds, so tells me that that's probably what I need to read up on. Thanks @Danial 🐝
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
And the code to actually process the event is
async execute(interaction) {
if (!interaction.isCommand()) return;

const aiQuestion = interaction.options.getString('question');

const openai = new OpenAI({ apiKey: openaiApiKey, engine: gptEngine });

try {
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: aiQuestion }],
});
const question = `${interaction.user.displayName} asked ${aiQuestion}`;
const answer = response.choices[0].message.content;
console.log(answer);

if (interaction.deferred) {
await interaction.followUp(`${question}\n\n${answer}`);
} else {
await interaction.reply(`${question}\n\n${answer}`);
}

} catch (error) {
await interaction.reply({
content: 'Sorry, I encountered an error while processing your request.',
ephemeral: true,
});
console.error('Error communicating with GPT-3.5:', error.message);
}
}
async execute(interaction) {
if (!interaction.isCommand()) return;

const aiQuestion = interaction.options.getString('question');

const openai = new OpenAI({ apiKey: openaiApiKey, engine: gptEngine });

try {
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: aiQuestion }],
});
const question = `${interaction.user.displayName} asked ${aiQuestion}`;
const answer = response.choices[0].message.content;
console.log(answer);

if (interaction.deferred) {
await interaction.followUp(`${question}\n\n${answer}`);
} else {
await interaction.reply(`${question}\n\n${answer}`);
}

} catch (error) {
await interaction.reply({
content: 'Sorry, I encountered an error while processing your request.',
ephemeral: true,
});
console.error('Error communicating with GPT-3.5:', error.message);
}
}
What really stumps me is that I'll get the error 1 time, but another the command works fine and the console.log always returns the answer just not sure if I'm handling the interaction wrong or what's going on there.
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/7/2023 in #djs-questions
Unknown Interaction. Not sure what the cause is
Part two..
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 12/5/2023 in #djs-questions
Global / Commands
Interesting. I’ll have to see what I messed up after work tomorrow. Thanks!
6 replies
DIAdiscord.js - Imagine an app
Created by Estal on 11/14/2023 in #djs-questions
First Example from the site doesn't work.
Fair enough. Was looking at the docs from 14.14.1; it's been a few years since I messed around with js really, but just changing the extension to mjs from js has helped
4 replies
CC#
Created by hulton fogan on 1/22/2023 in #help
❔ What could be causing the following issue (Method not found):
I'm finding something similar, but not exact where they needed the package from
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
and had to add the following usings to their directive
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
using Microsoft.Extensions.FileProviders;
6 replies
CC#
Created by hulton fogan on 1/22/2023 in #help
❔ What could be causing the following issue (Method not found):
Is it reliant on a Nugent Package?
6 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
PS. The Reason to reread it at the end there is that it should have all new values, so if they choose to display changes it helps to verify the file was actually changed
12 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
Okay, When you said why would you want to read the file you just saved it made me think some more. The answer was so obvious, so THANK YOU. Simply changed the data to
C#
string FullConfig = File.ReadAllText(ConfigFile);
FullConfig = FullConfig.Replace("SessionName=\"" + LoadSetting(ConfigFile, "SessionName") + "\"", "SessionName=\"" + serverName.Text + "\"");
FullConfig = FullConfig.Replace("JoinPassword=\"" + LoadSetting(ConfigFile, "JoinPassword") + "\"", "JoinPassword=\"" + serverPass.Text + "\"");
FullConfig = FullConfig.Replace("AdminPassword=\"" + LoadSetting(ConfigFile, "AdminPassword") + "\"", "AdminPassword=\"" + adminPass.Text + "\"");
FullConfig = FullConfig.Replace("MaxPlayers=" + LoadSetting(ConfigFile, "MaxPlayers"), "MaxPlayers=" + maxPlayers.Text);
FullConfig = FullConfig.Replace("ShutdownIfNotJoinedFor=" + LoadSetting(ConfigFile, "ShutdownIfNotJoinedFor"), "ShutdownIfNotJoinedFor=" + shutDownNotJoined1.Text);
FullConfig = FullConfig.Replace("ShutdownIfEmptyFor=" + LoadSetting(ConfigFile, "ShutdownIfEmptyFor"), "ShutdownIfEmptyFor=" + shutdownEmpty.Text);
FullConfig = FullConfig.Replace("ResumeProspect=" + LoadSetting(ConfigFile, "ResumeProspect"), "ResumeProspect=" + GetResumeStatus());
File.WriteAllText(ConfigFile, FullConfig);
string FinalConfig = File.ReadAllText(ConfigFile);
if (displayChanges.IsChecked == true)
{
MessageBox.Show(FinalConfig);
}
C#
string FullConfig = File.ReadAllText(ConfigFile);
FullConfig = FullConfig.Replace("SessionName=\"" + LoadSetting(ConfigFile, "SessionName") + "\"", "SessionName=\"" + serverName.Text + "\"");
FullConfig = FullConfig.Replace("JoinPassword=\"" + LoadSetting(ConfigFile, "JoinPassword") + "\"", "JoinPassword=\"" + serverPass.Text + "\"");
FullConfig = FullConfig.Replace("AdminPassword=\"" + LoadSetting(ConfigFile, "AdminPassword") + "\"", "AdminPassword=\"" + adminPass.Text + "\"");
FullConfig = FullConfig.Replace("MaxPlayers=" + LoadSetting(ConfigFile, "MaxPlayers"), "MaxPlayers=" + maxPlayers.Text);
FullConfig = FullConfig.Replace("ShutdownIfNotJoinedFor=" + LoadSetting(ConfigFile, "ShutdownIfNotJoinedFor"), "ShutdownIfNotJoinedFor=" + shutDownNotJoined1.Text);
FullConfig = FullConfig.Replace("ShutdownIfEmptyFor=" + LoadSetting(ConfigFile, "ShutdownIfEmptyFor"), "ShutdownIfEmptyFor=" + shutdownEmpty.Text);
FullConfig = FullConfig.Replace("ResumeProspect=" + LoadSetting(ConfigFile, "ResumeProspect"), "ResumeProspect=" + GetResumeStatus());
File.WriteAllText(ConfigFile, FullConfig);
string FinalConfig = File.ReadAllText(ConfigFile);
if (displayChanges.IsChecked == true)
{
MessageBox.Show(FinalConfig);
}
12 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
I'll give it a go. New approach for me. Thanks
12 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
that just feels like a headache though lol
12 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
Suppose I could have it read->Serialize->Update->SaveNew->ReadNew->Deserialize->Save
12 replies
CC#
Created by Estal on 1/13/2023 in #help
❔ Replace multiple Lines
Unfortunately it's not. 😦 It's an ini file for a server that the program handles.
12 replies
CC#
Created by Estal on 1/12/2023 in #help
❔ Updating text on main thread from running application WPF C Sharp
I got it working. Seems like it's a steamcmd thing, but on the server it runs it's got a decent delay as well, so will look into that.
6 replies
CC#
Created by Estal on 1/12/2023 in #help
❔ Updating text on main thread from running application WPF C Sharp
will do. thanks
6 replies