Skip to content

Commit

Permalink
thingID to thingId - break break break
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 8, 2021
1 parent 51d6852 commit b2941bc
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 184 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ client.on('messageCreate', (message) => {
winnerCount: parseInt(args[1]),
prize: args.slice(2).join(' ')
}).then((gData) => {
console.log(gData); // {...} (messageID, end date and more)
console.log(gData); // {...} (messageId, end date and more)
});
// And the giveaway has started!
}
Expand Down Expand Up @@ -127,14 +127,14 @@ This allows you to start a new giveaway. Once the `start()` function is called,
</a>

#### ⚠ ATTENTION!
The command examples below (reroll, edit delete, end) can be executed on any server your bot is a member of if a person has the `prize` or the `messageID`of a giveaway. To prevent abuse we recommend to check if the `prize` or the `messageID` that was provided by the command user is for a giveaway on the same server, if it is not, then cancel the command execution.
The command examples below (reroll, edit delete, end) can be executed on any server your bot is a member of if a person has the `prize` or the `messageId`of a giveaway. To prevent abuse we recommend to check if the `prize` or the `messageId` that was provided by the command user is for a giveaway on the same server, if it is not, then cancel the command execution.

```js
let giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find((g) => g.guildID === message.guild.id && g.prize === args.join(' ')) ||
// Search with messageID
client.giveawaysManager.giveaways.find((g) => g.guildID === message.guild.id && g.messageID === args[0]);
client.giveawaysManager.giveaways.find((g) => g.guildId === message.guild.id && g.prize === args.join(' ')) ||
// Search with messageId
client.giveawaysManager.giveaways.find((g) => g.guildId === message.guild.id && g.messageId === args[0]);

// If no giveaway was found
if (!giveaway) return message.channel.send('Unable to find a giveaway for `'+ args.join(' ') +'`.');
Expand All @@ -148,8 +148,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'reroll') {
const messageID = args[0];
client.giveawaysManager.reroll(messageID).then(() => {
const messageId = args[0];
client.giveawaysManager.reroll(messageId).then(() => {
message.channel.send('Success! Giveaway rerolled!');
}).catch((err) => {
message.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
Expand All @@ -173,8 +173,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'edit') {
const messageID = args[0];
client.giveawaysManager.edit(messageID, {
const messageId = args[0];
client.giveawaysManager.edit(messageId, {
addTime: 5000,
newWinnerCount: 3,
newPrize: 'New Prize!'
Expand Down Expand Up @@ -206,8 +206,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'delete') {
const messageID = args[0];
client.giveawaysManager.delete(messageID).then(() => {
const messageId = args[0];
client.giveawaysManager.delete(messageId).then(() => {
message.channel.send('Success! Giveaway deleted!');
}).catch((err) => {
message.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
Expand All @@ -228,8 +228,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'end') {
const messageID = args[0];
client.giveawaysManager.end(messageID).then(() => {
const messageId = args[0];
client.giveawaysManager.end(messageId).then(() => {
message.channel.send('Success! Giveaway ended!');
}).catch((err) => {
message.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
Expand All @@ -246,8 +246,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'pause') {
const messageID = args[0];
client.giveawaysManager.pause(messageID).then(() => {
const messageId = args[0];
client.giveawaysManager.pause(messageId).then(() => {
message.channel.send('Success! Giveaway paused!');
}).catch((err) => {
message.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
Expand All @@ -270,8 +270,8 @@ client.on('messageCreate', (message) => {
const command = args.shift().toLowerCase();

if (command === 'unpause') {
const messageID = args[0];
client.giveawaysManager.unpause(messageID).then(() => {
const messageId = args[0];
client.giveawaysManager.unpause(messageId).then(() => {
message.channel.send('Success! Giveaway unpaused!');
}).catch((err) => {
message.channel.send(`An error has occurred, please check and try again.\n\`${err}\``);
Expand All @@ -286,8 +286,8 @@ client.on('messageCreate', (message) => {
// A list of all the giveaways
const allGiveaways = client.giveawaysManager.giveaways; // [ {Giveaway}, {Giveaway} ]

// A list of all the giveaways on the server with ID "1909282092"
const onServer = client.giveawaysManager.giveaways.filter(g => g.guildID === '1909282092');
// A list of all the giveaways on the server with Id "1909282092"
const onServer = client.giveawaysManager.giveaways.filter(g => g.guildId === '1909282092');

// A list of the current active giveaways (not ended)
const notEnded = client.giveawaysManager.giveaways.filter(g => !g.ended);
Expand Down Expand Up @@ -467,7 +467,7 @@ client.giveawaysManager.start(message.channel, {
And for the `reroll()` function:

```js
client.giveawaysManager.reroll(messageID, {
client.giveawaysManager.reroll(messageId, {
messages: {
congrat: ':tada: New winner(s): {winners}! Congratulations, you won **{prize}**!\n{messageURL}',
error: 'No valid participations, no new winner(s) can be chosen!'
Expand Down
12 changes: 6 additions & 6 deletions examples/custom-databases/enmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
giveawayDB.set(messageID, giveawayData);
giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
// Replace the unedited giveaway with the edited giveaway
giveawayDB.set(messageID, giveawayData);
giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
// Remove the giveaway from the database
giveawayDB.delete(messageID);
giveawayDB.delete(messageId);
// Don't forget to return something!
return true;
}
Expand Down
22 changes: 11 additions & 11 deletions examples/custom-databases/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ db.once('open', () => {

// Create the schema for giveaways
const giveawaySchema = new mongoose.Schema({
messageID: String,
channelID: String,
guildID: String,
messageId: String,
channelId: String,
guildId: String,
startAt: Number,
endAt: Number,
ended: Boolean,
Expand All @@ -47,7 +47,7 @@ const giveawaySchema = new mongoose.Schema({
},
thumbnail: String,
hostedBy: String,
winnerIDs: [String],
winnerIds: [String],
reaction: mongoose.Mixed,
botsCanWin: Boolean,
embedColor: mongoose.Mixed,
Expand Down Expand Up @@ -83,25 +83,25 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await giveawayModel.create(giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
// Find by messageID and update it
await giveawayModel.findOneAndUpdate({ messageID: messageID }, giveawayData, { omitUndefined: true }).exec();
async editGiveaway(messageId, giveawayData) {
// Find by messageId and update it
await giveawayModel.findOneAndUpdate({ messageId: messageId }, giveawayData, { omitUndefined: true }).exec();
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
// Find by messageID and delete it
await giveawayModel.findOneAndDelete({ messageID: messageID }).exec();
async deleteGiveaway(messageId) {
// Find by messageId and delete it
await giveawayModel.findOneAndDelete({ messageId: messageId }).exec();
// Don't forget to return something!
return true;
}
Expand Down
14 changes: 7 additions & 7 deletions examples/custom-databases/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sql.connect((err) => {
console.error('Impossible to connect to MySQL server. Code: ' + err.code);
process.exit(99); // Stop the process if we can't connect to the MySQL server
} else {
console.log('[SQL] Connected to the MySQL server! Connection ID: ' + sql.threadId);
console.log('[SQL] Connected to the MySQL server! Connection Id: ' + sql.threadId);
}
});

Expand Down Expand Up @@ -54,9 +54,9 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
return new Promise((resolve, reject) => {
sql.query('INSERT INTO `giveaways` (`message_id`, `data`) VALUES (?,?)', [messageID, JSON.stringify(giveawayData)], (err, res) => {
sql.query('INSERT INTO `giveaways` (`message_id`, `data`) VALUES (?,?)', [messageId, JSON.stringify(giveawayData)], (err, res) => {
if (err) {
console.error(err);
return reject(err);
Expand All @@ -67,9 +67,9 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
return new Promise((resolve, reject) => {
sql.query('UPDATE `giveaways` SET `data` = ? WHERE `message_id` = ?', [JSON.stringify(giveawayData), messageID], (err, res) => {
sql.query('UPDATE `giveaways` SET `data` = ? WHERE `message_id` = ?', [JSON.stringify(giveawayData), messageId], (err, res) => {
if (err) {
console.error(err);
return reject(err);
Expand All @@ -80,9 +80,9 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
return new Promise((resolve, reject) => {
sql.query('DELETE FROM `giveaways` WHERE `message_id` = ?', messageID, (err, res) => {
sql.query('DELETE FROM `giveaways` WHERE `message_id` = ?', messageId, (err, res) => {
if (err) {
console.error(err);
return reject(err);
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-databases/quick.db.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
db.push('giveaways', giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = db.get('giveaways');
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
Expand All @@ -40,11 +40,11 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = db.get('giveaways');
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Save the updated array
db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-databases/quick.replit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await db.push('giveaways', giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
Expand All @@ -40,11 +40,11 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Save the updated array
await db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-databases/quickmongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await db.push('giveaways', giveawayData);
// Don't forget to return something!
return true;
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
Expand All @@ -40,11 +40,11 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Save the updated array
await db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
Expand Down
10 changes: 5 additions & 5 deletions examples/custom-databases/replit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageID, giveawayData) {
async saveGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveawaysArray = await db.get('giveaways');
// Push the new giveaway into the array
Expand All @@ -33,11 +33,11 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
Expand All @@ -47,11 +47,11 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
}

// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageID) {
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = await db.get('giveaways');
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageId !== messageId);
// Save the updated array
await db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
Expand Down
Loading

0 comments on commit b2941bc

Please sign in to comment.