How to use the sqlite.get function in sqlite

To help you get started, we’ve selected a few sqlite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github invalidCards / WikiaLinker / wikilinker.js View on Github external
sql.get(`SELECT * FROM guilds WHERE id="${msg.guild.id}"`).then(row => {
		if (!row.mainWiki) {
			return msg.channel.send([
				'This server has not set a default wiki yet.',
				`Users with the "Administrator" permission can do this using ${config.prefix}swiki .`
			]);
		}

		sql.get(`SELECT * FROM guilds WHERE id="${msg.guild.id}"`).then(lowrow => {
			let wiki = lowrow.mainWiki;

			sql.all(`SELECT * FROM overrides WHERE guildID="${msg.guild.id}"`).then(rows => {
				let forbidden = ['runescape', 'oldschoolrunescape', 'rs', 'osrs', '2007.runescape'];
				if (rows.length !== 0) {
					for (let i = 0; i < rows.length; i++) {
						if (rows[i].channelID === msg.channel.id) {
							wiki = rows[i].wiki;
						}
					}
				}
				if (throughCommand) {
					if (forbidden.includes(wiki)) {
						msg.reply([
							'The RuneScape and Old School RuneScape wikis have forked away from Wikia!',
							'For more information, see .',
github Syntheti / Orcinus / commands / automod.js View on Github external
exports.run = (client, message, args) => {
    if (!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("You're missing MANAGE_GUILD permission");
    if (!message.guild.member(client.user).hasPermission('MANAGE_MESSAGES')) return message.reply('Sorry, i dont have the perms to do this cmd i need MANAGE_MESSAGES. :x:')
    sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
        const prefixtouse = row.prefix
        const embed10 = new Discord.RichEmbed()
                .setColor(0x00A2E8)
                .setThumbnail(client.user.avatarURL)
                .setTitle("Command: " + prefixtouse + "automod")
                .addField("Usage", prefixtouse + "automod [enable/disable] [antiinvite/antiweblink/antidupcharacters]")
                .addField("Example", prefixtouse + "automod enable antiinvite")
                .setDescription("Description: " + "Enables/disables the bots auto moderation.");

        const toenable = args[0]
        const thingtoenable = args.slice(1).join(` `);
        if (toenable < 1) return message.channel.send(embed10)
        if (thingtoenable < 1) return message.channel.send(embed10)

                if (toenable === "enable" && thingtoenable === "antiinvite") {
                       sql.run(`UPDATE scores SET automoderation = "enabled", invitelinkprotection = "enabled", casenumber = ${row.casenumber + 1} WHERE guildId = ${message.guild.id}`);
github Syntheti / Orcinus / commands / hackban.js View on Github external
exports.run = async (client, message, args) => {
  sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
  const prefixtouse = row.prefix
  const usage = new Discord.RichEmbed()
            .setColor(0x00A2E8)
            .setThumbnail(client.user.avatarURL)
            .setTitle("Command: " + prefixtouse + "hackban")
            .addField("Usage", prefixtouse + "hackban  ")
            .addField("Example", prefixtouse + "hackban 130515926117253122 self bot that dms server links and left.")
            .setDescription("Description: " + "Bans a user without needing to be in the server");

  if (message.member.hasPermission("BAN_MEMBERS")) {
  if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) return message.reply('Sorry, i dont have the perms to do this cmd i need BAN_MEMBERS. :x:')
  let user = args[0]
  if (isNaN(user)) return message.channel.send(usage)
  let reason = args[1] || `Moderator didn't give a reason.`;
  if (isNaN(user)) return message.channel.send(usage)
  if (!user) return message.reply('You must supply a User Resolvable, such as a user id.')
github bhj / karaoke-forever / server / Prefs / Prefs.js View on Github external
static async getJwtKey () {
    const query = sql`
      SELECT * FROM prefs
      WHERE key = "jwtKey"
    `
    const row = await db.get(String(query), query.parameters)

    if (row && row.data) {
      const jwtKey = JSON.parse(row.data)

      if (jwtKey.length === 64) {
        return jwtKey
      }
    }

    return this.jwtKeyRefresh()
  }
github cheshire137 / hue-steamer / src / server.js View on Github external
server.get('/bridge', async (req, res) => {
  const result = await db.get('SELECT COUNT(*) AS count FROM bridges');
  if (result.count < 1) {
    res.status(400).json({ error: 'There are no bridges.' });
    return;
  }
  const connection = await getBridge();
  sendBridgeDetails(connection, res);
});
github Syntheti / Orcinus / events / messageDelete.js View on Github external
module.exports = (client, message) => {
    if (message.author.bot) return;
    if (message.channel.type === 'dm') return;
    if (!message.guild.member(client.user).hasPermission('SEND_MESSAGES')) return;
    if (!message.guild.member(client.user).hasPermission('VIEW_CHANNEL')) return;
    if (!message.guild.member(client.user).hasPermission('READ_MESSAGE_HISTORY')) return;

    sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
    if (row.slowmode === "enabled") return;
    if (message.author.bot) return;
    if (message.channel.type !== 'text') return;
    const description = message.cleanContent
    const descriptionfix = description.substr(0, 600);
    let guild = message.guild;
    let modlog = guild.channels.find(channel => channel.name == row.logschannel);
     if (!modlog) return;
    const embed = new Discord.RichEmbed()
    .setColor(0x00A2E8)
    .setThumbnail(message.author.avatarURL)
    .addField("Author ", `${message.author.tag} (ID: ${message.author.id})`, true)
    .addField("Message Content:", `${descriptionfix}`, true)
    .setTimestamp()
    .setFooter("Message delete in " + message.channel.name);
    client.channels.get(modlog.id).send({embed});
github Syntheti / Orcinus / events / messageUpdate.js View on Github external
module.exports = (client, message, editedMessage) => {
  if (message.author.bot) return;
  if (message.channel.type === 'dm') return;
  if (!message.guild.member(client.user).hasPermission('SEND_MESSAGES')) return;
    if (!message.guild.member(client.user).hasPermission('EMBED_LINKS')) return;
    if (!message.guild.member(client.user).hasPermission('VIEW_CHANNEL')) return;
    if (!message.guild.member(client.user).hasPermission('READ_MESSAGE_HISTORY')) return;
    sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
    if (message.author.bot) return;
    if (message === editedMessage) return;
    if (message.channel.type !== 'text') return;
    let guild = message.guild;
    let modlog = guild.channels.find(channel => channel.name == row.logschannel);
     if (!modlog) return;
    const embed = new Discord.RichEmbed()
    .setColor(0x00A2E8)
    .setThumbnail(message.author.avatarURL)
    .addField("Author ", `${message.author.tag} (ID: ${message.author.id})`, true)
    .addField("Before Edit ", `${message}`, true)
    .addField("After Edit", `${editedMessage}`, true)
    .setTimestamp()
    .setFooter("Message edit in " + message.channel.name);
    if (message.content.includes("http")) return;
    if (message.content.includes("www.")) return;
github invalidCards / WikiaLinker / wikilinker.js View on Github external
noinline: (msg) => {
		sql.get(`SELECT disableInline FROM guilds WHERE id=${msg.guild.id}`).then(guild => {
			let enabled = guild.disableInline == 1;
			sql.run('UPDATE guilds SET disableInline=? WHERE id=?', [enabled ? 0 : 1, msg.guild.id]).then(() => {
				msg.reply(`the ability to use inline links has been toggled ${enabled ? 'on' : 'off'}.`);
			});
		});
	}
};
github Syntheti / Orcinus / commands / prefix.js View on Github external
exports.run = (client, message, args) => {
     if (!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("You are missing MANAGE_GUILD permission");
     const newprefix = args[0]
     const newprefixfix = newprefix.replace(/[^\x00-\x7F]/g, "");
     if (newprefix.length < 1) return message.channel.send("Didn't provide a new prefix to set")
     if (newprefixfix.length < 1) return message.channel.send("Prefix can't have ascii characters")
     if (newprefix.length > 7) return message.channel.send("prefix can't be longer then 7 characters")
     sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
     sql.run(`UPDATE scores SET prefix = "${newprefixfix}", casenumber = ${row.casenumber + 1} WHERE guildId = ${message.guild.id}`);
     message.channel.send("I have set the new guild prefix to " + newprefix)
     let modlog = message.guild.channels.find(channel => channel.name == row.logschannel);
      const embed = new Discord.RichEmbed()
        .setColor(0x00A2E8)
        .setTitle("Case #" + row.casenumber + " | Action: Prefix Change")
        .addField("Moderator", message.author.tag + " (ID: " + message.author.id + ")")
        .addField("New prefix", newprefixfix, true)
        .setFooter("Time used: " + message.createdAt.toDateString())
      if (!modlog) return;
      if (row.logsenabled === "disabled") return;
    return client.channels.get(modlog.id).send({embed});
    })
}
github Syntheti / Orcinus / Main.js View on Github external
if (row.awards.includes("None")) return sql.run(`UPDATE profiles SET awards = "" WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);
            if (row.awards.includes(":moneybag:")) return;
            sql.run(`UPDATE profiles SET awards = "${row.awards + " :moneybag:"}" WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);
          } else if (row.cash >= 100000) {
            if (row.awards.includes("None")) return sql.run(`UPDATE profiles SET awards = "" WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);
            if (row.awards.includes(":credit_card:")) return;
            sql.run(`UPDATE profiles SET awards = "${row.awards + " :credit_card:"}" WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);
          } else {
            return;
          }
       });
    });
    }

  if (message.content.startsWith("")) {
    sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row2 => {
      if (!row2) return;
      if (row2.levelsystem === "disabled") return;
    if (talkedRecently.has(message.author.id)) return;
    const xpgained = Math.floor(Math.random() * 15) + 1;
    sql.get(`SELECT * FROM profiles WHERE guildId ="${message.guild.id}" AND userId ="${message.author.id}"`).then(row => {
      if (!row) {
          sql.run("INSERT INTO profiles (guildId, userId, xp, level, bank, cash, awards, rep, username, winningchance) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [message.guild.id, message.author.id, 0, 1, 0, 100, "None", 0, message.author.username, 0]);
        } else {
          let curLevel = Math.floor(0.1 * Math.sqrt(row.xp + 1));
          if (curLevel > row.level) {
            row.level = curLevel;
            if (row.level >= 300) return;
            sql.run(`UPDATE profiles SET xp = ${row.xp + xpgained}, level = ${row.level} WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);
          }
          if (row.xp >= 9999999) return;
          sql.run(`UPDATE profiles SET xp = ${row.xp + xpgained}, cash = ${row.cash + 10}, username = "${message.author.username}" WHERE guildId ="${message.guild.id}" AND userId = ${message.author.id}`);

sqlite

SQLite client for Node.js applications with SQL-based migrations API written in Typescript

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis