#How do I connect my database to my Discord bot?
1 messages · Page 1 of 1 (latest)
ok yes, but how?
Add TicketMessage to your CommandHandler constructor. If you are using an IoC container, register the dependency.
what is an IoC
inversion of control container, such as IServiceCollection. https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection?view=dotnet-plat-ext-7.0
ok so and another question, why is the
cmd.Parameters["@Id"].Value = TicketMessage.Id;
cmd.Parameters["@Description"].Value = TicketMessage.Description;
cmd.Parameters["@PingGuid"].Value = TicketMessage.PingGuid;
cmd.Parameters["@Number"].Value = TicketMessage.Number;
cmd.Parameters["@TicketGuid"].Value = TicketMessage.TicketGuid;```
gone red
Looks like your datatype should be ticket not TicketMessage
why ticket?
it says that TicketMessage does not contain a definition of Id and all of the others that are red.
TicketMessage seems to be your class you use for interacting with the database. You have another file alongside it, ticket.cs, that I would guess has your object implementation
this is what is in the ticket.cs
I am trying to make a data module to store information for my ticket bot, I am recoding into cs
but cs is quite a bit different to js
They are the properties you are trying to access, so your method should be
public void SaveTicketmessage(Ticket ticket)
{
...
cmd.Parameters["@id"].Value = ticket.Id;
...
}
That seems out of scope of this server, I'd suggest referencing docs for your database provider
but, I am using the discord.net and c# so I feel like it is all part of this but sure
fwiw it looks like your SaveTicketmessage should already be able to save to your database, I don't think you need any changes aside from using the Ticket object
Oh.... cool 😄 thanks what about this, I can't seem to find anything on the discord.net website about how to make a link, I mean yes there is this link but it does not really tell about it.
https://discordnet.dev/guides/int_basics/message-components/buttons-in-depth.html#url
var button = new ComponentBuilder()
.WithButton("Invite Me", url:"discordlink", ButtonStyle.Link );```
[my text](https://discord.com/) should do it. If you want the url to be the text, [https://discord.com/](https://discord.com/)
its for a button link, I dont need a hyper link.
like this
Not sure what you are trying to do specifically, looks like it works
that is from my bot written in node.js, I am recoding it into discord.net
Try .WithButton("Invite Me", url: "https://...", style: ButtonStyle.Link);