What is wrong with quick.db

I have a logs command but my bot is unable to fetch it
Here is the code for the fetch command:

if (value == "logs") {
  let lID = db.get(`${message.guild.id}.lChannel`)
let lChannel = message.guild.channels.get(lID);
if (!lChannel) message.channel.send("There is no log channel set");
    if (lChannel) {
      const embed = new RichEmbed()
        .setTitle('Log Channel')
        .setDescription(`The log channel is ${lChannel}`)
      message.channel.send(embed)
      
}
}

PLEASE HELP!

@charliea21 do you know what is happening?

@glitch_support Please help me

Begging for support most likely won’t get you any support

You could’ve spent this time constructing your query more and therefore giving us more details so we can help. All I know so far is something isn’t working. What isn’t working? Is there any errors?

no errors. it just can’t fetch the data for some reason.

Where are you setting your log channel? What command and what contents does it contain

here is the set command:
if (args[0] === “logs”) {
let lChannel = message.mentions.channels.first();

        if (!lChannel) {
            message.channel.send("That channel could not be found");
        }
    
        await db.set(`${message.guild.id}.lChannel`, lChannel.id);
        
      let sembed = new RichEmbed()
  .setTitle("Success")
  .setColor("#3FC83B")

.setDescription(The log channel has been set to <#${lChannel.id}>)
message.channel.send(sembed);
}

In the get command, could you add
console.log(lID)
After let lID = ...
Then run the get command and tell me the output of console

already tried that lol and the output was the channel id

Are you sure for the channel fetch, you didn’t mean to have it as

db.get(`${message.guild.id}`).lChannel

Ok, we’ve eliminated the possibility the database is fetching incorrectly. Could you now log lChannel.name into the console?

quick.db supports dot notation

1 Like

ok i will try that. (gotta add more characters lol)

it does log the channel name which is “logs” @SpeedyCraftah

OK so I’m slightly confused. What’s the unexpected behavior you’re experiencing? Which command? What message comes up if any

Screen Shot 2020-02-28 at 9.40.43 PM
This is the unexpected behaviour @SpeedyCraftah

Since I have no idea what’s happening, i have rewrote the get code, please replace everything inside value == logs with:

const lID = db.get(`${message.guild.id}.lChannel`);
if (!lID) return message.channel.send("There is no log channel set");

const lChannel = message.guild.channels.get(lID);
if (!lChanel) return message.channel.send("The log channel has been removed, set a new one");

const Embed = new RichEmbed()
    .setTitle('Log Channel')
    .setDescription(`The log channel is ${lChannel}`);

message.channel.send(Embed);

and give the command a try again

still does not work :frowning:

can you log db.get(${message.guild.id}) after you save it

already did and it showed the change name

I have an eval command and I use a?eval db.fetch(642540263067222022.lChannel) and it DOES fetch the channel

So… that would mean that you’re not fetching it with the right guild id. Did you log both of them?

no for my eval command now I will try the message.guild.id thing

I doesn’t work idk why

I think I’ve got it. So you’re fetching the channel based upon the raw lID value. If the channel doesn’t exist then its not set. But, the lID is an array, so you would have to do…

let lChannel = message.guild.channels.get(lID[0]);
1 Like

ok I will try to use that

Thanks so much! that worked!!

Yay! That was driving me crazy, :smile:
Happy Glitching

wait a sec I have tried that with the welcome channel part and it doesn’t work for that one even though the id is there @edwrddd

send more information

show your code please

if (value == "welcome") {
  let wID = db.get(`${message.guild.id}.wChannel`)
let wChannel = message.guild.channels.get(wID[0]);
  if(!wChannel) return message.channel.send("There is no welcome channel set");
  
   const embed = new RichEmbed()
	.setTitle('Welcome Channel')
		.setDescription(`The welcome channel is ${wChannel}`)
   message.channel.send(embed)
}

That’s because the welcome id isn’t an array

1 Like

so should I remove the [0] ?

yes you should remove it

1 Like

Im so stupid lol now it works thanks so much

can you tell me how to delete that log channel array cus I want it to just be a value

run this in the eval command

db.set(`${message.guild.id}.lChannel`, "channel_id_here")

will that delete the other ones?

yes it should set the value of it to the singular channel id

ok lemme try you have been very helpful

It worked! Thank you so much