private async Task GetEmoteStats(CommandContext ctx, TempEmote emote, string interval) { var guild = ctx.Guild; var isValidEmote = IsValidMessageEmote(emote.Id, guild); if (!isValidEmote) { await ctx.RespondAsync("Invalid emote"); return; } var parsed = TryGetDateFromInterval(IntervalValue.Parse(interval), out var fromDate); if (!parsed) { await ctx.RespondAsync("Invalid interval"); return; } var request = new GetEmoteStatsRequest(ctx) { Emote = emote, FromDate = fromDate }; _commandQueue.Enqueue(request); }
/// <inheritdoc /> public override void VisitGenericIntervalValue <T>(IntervalValue <T> value) { switch (operation) { case Operations.Identical: result = OutSet.CreateBool(false); break; case Operations.NotIdentical: result = OutSet.CreateBool(true); break; default: result = Comparison.LeftAlwaysGreater(OutSet, operation); if (result != null) { break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { break; } base.VisitGenericIntervalValue(value); break; } }
/// <inheritdoc /> public override void VisitGenericIntervalValue <T>(IntervalValue <T> value) { switch (operation) { case Operations.Plus: result = value; break; case Operations.LogicNegation: bool nativeBooleanValue; if (TypeConversion.TryConvertToBoolean <T>(value, out nativeBooleanValue)) { result = OutSet.CreateBool(!nativeBooleanValue); } else { result = OutSet.AnyBooleanValue; } break; default: if (PerformUsualOperation(value)) { break; } base.VisitGenericIntervalValue(value); break; } }
/// <inheritdoc /> public override void VisitGenericIntervalValue <T>(IntervalValue <T> value) { // When comparing, both operands are converted to boolean switch (operation) { case Operations.Identical: case Operations.GreaterThan: case Operations.And: result = OutSet.CreateBool(false); break; case Operations.NotIdentical: case Operations.LessThanOrEqual: result = OutSet.CreateBool(true); break; case Operations.Equal: case Operations.GreaterThanOrEqual: bool booleanValue; if (TypeConversion.TryConvertToBoolean(value, out booleanValue)) { result = OutSet.CreateBool(!booleanValue); } else { result = OutSet.AnyBooleanValue; } break; case Operations.NotEqual: case Operations.LessThan: case Operations.Or: case Operations.Xor: BooleanValue convertedValue; if (TypeConversion.TryConvertToBoolean(OutSet, value, out convertedValue)) { result = convertedValue; } else { result = OutSet.AnyBooleanValue; } break; case Operations.BitAnd: case Operations.ShiftLeft: case Operations.ShiftRight: result = OutSet.CreateInt(0); break; default: base.VisitGenericIntervalValue(value); break; } }
/// <inheritdoc /> public override void VisitGenericIntervalValue <T>(IntervalValue <T> value) { result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { // It is too complicated to represend result of bitwise operation with interval return; } base.VisitGenericIntervalValue(value); }
/// <inheritdoc /> public override void VisitGenericIntervalValue <T>(IntervalValue <T> value) { switch (operation) { case Operations.Identical: result = OutSet.CreateBool(false); break; case Operations.NotIdentical: result = OutSet.CreateBool(true); break; default: base.VisitGenericIntervalValue(value); break; } }