Closed Dragonizedpizza closed 3 years ago
so are they marked as ended/deleted from the DB or just frozen = continue after another restart?
could you check client.giveawaysManager.giveaways.filter(g => !g.ended).length
between restarts to check that?
What's your updateCountdownEvery
and how many giveaways were approximately active at that time?
that is a good question
for some reason it just says 21 at all times
are they instantly frozen after the restart or do they update once/for some duration and then stop?
could you maybe try that: https://github.com/Androz2091/discord-giveaways/issues/210#issuecomment-774650273
yeah no I tried my own method, yours doesn't work
yeah no I tried my own method, yours doesn't work
ah hdym?
and g => g.messageID
does not return a boolean...
AHA
yeah no I tried my own method, yours doesn't work
ah hdym? and
g => g.messageID
does not return a boolean...
doesn't need to, the fact that it exists should give it output
like that, if its value is not undefined or null, it should come in the filter
just to improve my case
Or could you try Manager.js 398 (de branch= 407) to add await
, idk if that could maybe help
my host just went down
sec
@Nico105 this error when doing the false thing
@Nico105 this error when doing the false thing
client.giveawaysManager._init();
in your bot ready event, you got that?
I didn't, but it didn't fix the issue.
is it worth mentioning that I'm sharding?
const database = require("../schemas/giveaway");
const { GiveawaysManager } = require("discord-giveaways");
module.exports = class Gmanager extends GiveawaysManager {
async getAllGiveaways() {
return await database.find({});
}
async refreshStorage() {
// This should make all shard refreshing their cache with the updated database
return global.client.shard.broadcastEval(() =>
this.giveawaysManager.getAllGiveaways()
);
}
async saveGiveaway(messageID, giveawayData) {
await database.create(giveawayData);
return true;
}
async editGiveaway(messageID, giveawayData) {
await database
.findOneAndUpdate({ messageID: messageID }, giveawayData)
.exec();
return true;
}
async deleteGiveaway(messageID) {
await database.findOneAndDelete({ messageID: messageID }).exec();
return true;
}
};
this.giveawaysManager = new giveawaysManager(this, {
updateCountdownEvery: 6969,
default: {
botsCanWin: false,
exemptPermissions: [],
embedColor: "#034ea2",
reaction: "🎉",
},
}, false);```
const database = require("../schemas/giveaway"); const { GiveawaysManager } = require("discord-giveaways"); module.exports = class Gmanager extends GiveawaysManager { async getAllGiveaways() { return await database.find({}); } async refreshStorage() { // This should make all shard refreshing their cache with the updated database return global.client.shard.broadcastEval(() => this.giveawaysManager.getAllGiveaways() ); } async saveGiveaway(messageID, giveawayData) { await database.create(giveawayData); return true; } async editGiveaway(messageID, giveawayData) { await database .findOneAndUpdate({ messageID: messageID }, giveawayData) .exec(); return true; } async deleteGiveaway(messageID) { await database.findOneAndDelete({ messageID: messageID }).exec(); return true; } };
check if the .find({})
returns values
is it worth mentioning that I'm sharding?
it should not really matter
what is the giveaways length before and after a restart without the filter?
Query {
_mongooseOptions: {},
_transforms: [],
_hooks: Kareem { _pres: Map(0) {}, _posts: Map(0) {} },
_executionCount: 0,
mongooseCollection: NativeCollection {
collection: null,
Promise: [Function: Promise],
_closed: false,
opts: {
schemaUserProvidedOptions: {},
capped: false,
autoCreate: undefined,
Promise: [Function: Promise],
'$wasForceClosed': undefined
},
name: 'giveaways',
collectionName: 'giveaways',
conn: NativeConnection {
base: [Mongoose],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
options: null,
otherDbs: [],
relatedDbs: {},
states: [Object: null prototype],
_readyState: 0,
_closeCalled: false,
_hasOpened: false,
plugins: [],
id: 0,
_queue: [],
_listening: false
},
queue: [],
buffer: true,
emitter: EventEmitter {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
[Symbol(kCapture)]: false
}
},
model: Model { giveaway },
schema: Schema {
obj: { giveaways: [Object] },
paths: {
'giveaways.messageID': [SchemaString],
'giveaways.channelID': [SchemaString],
'giveaways.guildID': [SchemaString],
'giveaways.startAt': [SchemaNumber],
'giveaways.endAt': [SchemaNumber],
'giveaways.ended': [SchemaBoolean],
'giveaways.winnerCount': [SchemaNumber],
'giveaways.prize': [SchemaString],
'giveaways.extraData': [Mixed],
'giveaways.messages.giveaway': [SchemaString],
'giveaways.messages.giveawayEnded': [SchemaString],
'giveaways.messages.inviteToParticipate': [SchemaString],
'giveaways.messages.timeRemaining': [SchemaString],
'giveaways.messages.winMessage': [SchemaString],
'giveaways.messages.embedFooter': [SchemaString],
'giveaways.messages.noWinner': [SchemaString],
'giveaways.messages.winners': [SchemaString],
'giveaways.messages.endedAt': [SchemaString],
'giveaways.messages.hostedBy': [SchemaString],
'giveaways.messages.units.seconds': [SchemaString],
'giveaways.messages.units.minutes': [SchemaString],
'giveaways.messages.units.hours': [SchemaString],
'giveaways.messages.units.days': [SchemaString],
'giveaways.messages.units.pluralS': [SchemaBoolean],
'giveaways.hostedBy': [SchemaString],
'giveaways.winnerIDs': [SchemaArray],
'giveaways.reaction': [SchemaString],
'giveaways.botsCanWin': [SchemaBoolean],
'giveaways.embedColor': [SchemaString],
'giveaways.embedColorEnd': [SchemaString],
'giveaways.exemptPermissions': [SchemaArray],
_id: [ObjectId],
__v: [SchemaNumber]
},
aliases: {},
subpaths: {
'giveaways.winnerIDs.$': [Mixed],
'giveaways.exemptPermissions.$': [Mixed]
},
virtuals: { id: [VirtualType] },
singleNestedPaths: {},
nested: {
giveaways: true,
'giveaways.messages': true,
'giveaways.messages.units': true
},
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
methodOptions: {},
statics: {},
tree: {
giveaways: [Object],
_id: [Object],
__v: [Function: Number],
id: [VirtualType]
},
query: {},
childSchemas: [],
plugins: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
'$id': 1,
s: { hooks: [Kareem] },
_userProvidedOptions: {},
options: {
typePojoToMixed: true,
typeKey: 'type',
id: true,
noVirtualId: false,
_id: true,
noId: false,
validateBeforeSave: true,
read: null,
shardKey: null,
autoIndex: null,
minimize: true,
discriminatorKey: '__t',
optimisticConcurrency: false,
versionKey: '__v',
capped: false,
bufferCommands: true,
strictQuery: false,
strict: true,
pluralization: true
},
'$globalPluginsApplied': true
},
op: 'find',
options: {},
_conditions: {},
_fields: undefined,
_update: undefined,
_path: undefined,
_distinct: undefined,
_collection: NodeCollection {
collection: NativeCollection {
collection: null,
Promise: [Function: Promise],
_closed: false,
opts: [Object],
name: 'giveaways',
collectionName: 'giveaways',
conn: [NativeConnection],
queue: [],
buffer: true,
emitter: [EventEmitter]
},
collectionName: 'giveaways'
},
_traceFunction: undefined,
'$useProjection': true
}
Query { _mongooseOptions: {}, _transforms: [], _hooks: Kareem { _pres: Map(0) {}, _posts: Map(0) {} }, _executionCount: 0, mongooseCollection: NativeCollection { collection: null, Promise: [Function: Promise], _closed: false, opts: { schemaUserProvidedOptions: {}, capped: false, autoCreate: undefined, Promise: [Function: Promise], '$wasForceClosed': undefined }, name: 'giveaways', collectionName: 'giveaways', conn: NativeConnection { base: [Mongoose], collections: [Object], models: [Object], config: [Object], replica: false, options: null, otherDbs: [], relatedDbs: {}, states: [Object: null prototype], _readyState: 0, _closeCalled: false, _hasOpened: false, plugins: [], id: 0, _queue: [], _listening: false }, queue: [], buffer: true, emitter: EventEmitter { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, [Symbol(kCapture)]: false } }, model: Model { giveaway }, schema: Schema { obj: { giveaways: [Object] }, paths: { 'giveaways.messageID': [SchemaString], 'giveaways.channelID': [SchemaString], 'giveaways.guildID': [SchemaString], 'giveaways.startAt': [SchemaNumber], 'giveaways.endAt': [SchemaNumber], 'giveaways.ended': [SchemaBoolean], 'giveaways.winnerCount': [SchemaNumber], 'giveaways.prize': [SchemaString], 'giveaways.extraData': [Mixed], 'giveaways.messages.giveaway': [SchemaString], 'giveaways.messages.giveawayEnded': [SchemaString], 'giveaways.messages.inviteToParticipate': [SchemaString], 'giveaways.messages.timeRemaining': [SchemaString], 'giveaways.messages.winMessage': [SchemaString], 'giveaways.messages.embedFooter': [SchemaString], 'giveaways.messages.noWinner': [SchemaString], 'giveaways.messages.winners': [SchemaString], 'giveaways.messages.endedAt': [SchemaString], 'giveaways.messages.hostedBy': [SchemaString], 'giveaways.messages.units.seconds': [SchemaString], 'giveaways.messages.units.minutes': [SchemaString], 'giveaways.messages.units.hours': [SchemaString], 'giveaways.messages.units.days': [SchemaString], 'giveaways.messages.units.pluralS': [SchemaBoolean], 'giveaways.hostedBy': [SchemaString], 'giveaways.winnerIDs': [SchemaArray], 'giveaways.reaction': [SchemaString], 'giveaways.botsCanWin': [SchemaBoolean], 'giveaways.embedColor': [SchemaString], 'giveaways.embedColorEnd': [SchemaString], 'giveaways.exemptPermissions': [SchemaArray], _id: [ObjectId], __v: [SchemaNumber] }, aliases: {}, subpaths: { 'giveaways.winnerIDs.$': [Mixed], 'giveaways.exemptPermissions.$': [Mixed] }, virtuals: { id: [VirtualType] }, singleNestedPaths: {}, nested: { giveaways: true, 'giveaways.messages': true, 'giveaways.messages.units': true }, inherits: {}, callQueue: [], _indexes: [], methods: {}, methodOptions: {}, statics: {}, tree: { giveaways: [Object], _id: [Object], __v: [Function: Number], id: [VirtualType] }, query: {}, childSchemas: [], plugins: [ [Object], [Object], [Object], [Object], [Object], [Object] ], '$id': 1, s: { hooks: [Kareem] }, _userProvidedOptions: {}, options: { typePojoToMixed: true, typeKey: 'type', id: true, noVirtualId: false, _id: true, noId: false, validateBeforeSave: true, read: null, shardKey: null, autoIndex: null, minimize: true, discriminatorKey: '__t', optimisticConcurrency: false, versionKey: '__v', capped: false, bufferCommands: true, strictQuery: false, strict: true, pluralization: true }, '$globalPluginsApplied': true }, op: 'find', options: {}, _conditions: {}, _fields: undefined, _update: undefined, _path: undefined, _distinct: undefined, _collection: NodeCollection { collection: NativeCollection { collection: null, Promise: [Function: Promise], _closed: false, opts: [Object], name: 'giveaways', collectionName: 'giveaways', conn: [NativeConnection], queue: [], buffer: true, emitter: [EventEmitter] }, collectionName: 'giveaways' }, _traceFunction: undefined, '$useProjection': true }
ah did you do console.log(await database)
?
i meant console.log(await database.find({}))
that is what I did except I didn't await it
ahm could you show me your schema file because for me it look like this
ahm could you show me your schema file because for me it look like this
const { model, Schema } = require("mongoose");
module.exports = model(
"giveaway",
new Schema({
giveaways: {
messageID: String,
channelID: String,
guildID: String,
startAt: Number,
endAt: Number,
ended: Boolean,
winnerCount: Number,
prize: String,
extraData: {
role: String,
},
messages: {
giveaway: String,
giveawayEnded: String,
inviteToParticipate: String,
timeRemaining: String,
winMessage: String,
embedFooter: String,
noWinner: String,
winners: String,
endedAt: String,
hostedBy: String,
units: {
seconds: String,
minutes: String,
hours: String,
days: String,
pluralS: Boolean,
},
},
hostedBy: String,
winnerIDs: [],
reaction: String,
botsCanWin: Boolean,
embedColor: String,
embedColorEnd: String,
exemptPermissions: [],
extraData: {},
},
})
);
why do you make an extra object? you don't store anything else in the giveaway model so that isn't needed and it also isn't in the example
I think I forgot to remove it from when I was making all the schemas one
yeah, remove it, that's very likely the reason why nothing safes properly
const db = mongoose.connection;
db.giveaways = model();
db.stuff1 = model();
db.stuff2 = model();
this is how you should seperate your data after all (I think)
I do do that, and thanks works
When I reboot my bot, or the process gets killed, the giveaway does not continue.
Sometimes it does, but sometimes it doesn't.
I think the causes could be: The MongoDB connection disconnecting and connecting again. The giveaway timestamp being passed. idk