C
C#SylveonDeko

❔ Im gonna lose my fucking mind over this

S-IERRA
S-IERRA272d ago
whats wrong
SylveonDeko
SylveonDeko272d ago
that^
Angius
Angius272d ago
what
SylveonDeko
SylveonDeko272d ago
channel is not null but it returns prematurely but doesnt touch the actual return;
S-IERRA
S-IERRA272d ago
ur on ridewr?
SylveonDeko
SylveonDeko272d ago
correct
S-IERRA
S-IERRA272d ago
S-IERRA
S-IERRA272d ago
igh sick run w debugger and hover over the variable for me
SylveonDeko
SylveonDeko272d ago
its on lol
Angius
Angius272d ago
It's really hard to say what's wrong by just seeing 3 lines of code
S-IERRA
S-IERRA272d ago
can u hover over the var and show me what the values are
SylveonDeko
SylveonDeko272d ago
now, why do you think im saying its not null?
onefuture
onefuture272d ago
@new FuckPremiumBots() have you considered this
onefuture
onefuture272d ago
PHP: Hypertext Preprocessor
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.
S-IERRA
S-IERRA272d ago
f10
blinkbat
blinkbat272d ago
...why
Jimmacle
Jimmacle272d ago
this is not a helpful suggestion
SylveonDeko
SylveonDeko272d ago
wat.
S-IERRA
S-IERRA272d ago
see what it says ah ok
onefuture
onefuture272d ago
im guessing you are using discord.net right?
SylveonDeko
SylveonDeko272d ago
yes
onefuture
onefuture272d ago
GitHub
GitHub - discord-php/DiscordPHP: An API to interact with the popula...
An API to interact with the popular messaging app Discord - GitHub - discord-php/DiscordPHP: An API to interact with the popular messaging app Discord
S-IERRA
S-IERRA272d ago
@new FuckPremiumBots() it could be that its failing to fetch the channel
onefuture
onefuture272d ago
heres a better alternative
Jimmacle
Jimmacle272d ago
are you trying to speedrun a ban?
SylveonDeko
SylveonDeko272d ago
how
S-IERRA
S-IERRA272d ago
S-IERRA
S-IERRA272d ago
here
SylveonDeko
SylveonDeko272d ago
im literally giving it the channel
S-IERRA
S-IERRA272d ago
yes but discord is weird had the same issue in py
SylveonDeko
SylveonDeko272d ago
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var gway = uow.Giveaways
.GiveawaysForGuild(ctx.Guild.Id).ToList().Find(x => x.MessageId == messageid);
if (gway is null)
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!").ConfigureAwait(false);

if (gway.Ended == 1)
await ctx.Channel.SendErrorAsync(
$"This giveaway has already ended! Plase use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!").ConfigureAwait(false);
else
{
var channel = await Context.Guild.GetTextChannelAsync(gway.ChannelId);
if (channel is null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!").ConfigureAwait(false);
return;
}
await Service.GiveawayTimerAction(gway, channel.Guild, channel).ConfigureAwait(false);
await ctx.Channel.SendConfirmAsync("Giveaway ended!").ConfigureAwait(false);
}
}
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var gway = uow.Giveaways
.GiveawaysForGuild(ctx.Guild.Id).ToList().Find(x => x.MessageId == messageid);
if (gway is null)
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!").ConfigureAwait(false);

if (gway.Ended == 1)
await ctx.Channel.SendErrorAsync(
$"This giveaway has already ended! Plase use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!").ConfigureAwait(false);
else
{
var channel = await Context.Guild.GetTextChannelAsync(gway.ChannelId);
if (channel is null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!").ConfigureAwait(false);
return;
}
await Service.GiveawayTimerAction(gway, channel.Guild, channel).ConfigureAwait(false);
await ctx.Channel.SendConfirmAsync("Giveaway ended!").ConfigureAwait(false);
}
}
S-IERRA
S-IERRA272d ago
uhm can you try to run w/o debugger
SylveonDeko
SylveonDeko272d ago
the method thats calling it ok
blinkbat
blinkbat272d ago
oh finally a whole block of code
onefuture
onefuture272d ago
almost blinded myself looking at that
SylveonDeko
SylveonDeko272d ago
you aint gonna have no future if you keep being an attention seeking brat let alone 1future
S-IERRA
S-IERRA272d ago
just ignore
blinkbat
blinkbat272d ago
that code block doesn't look like the bug you experienced
SylveonDeko
SylveonDeko272d ago
ik, just had to get that out
onefuture
onefuture272d ago
ask chat gpt to optimize it
SylveonDeko
SylveonDeko272d ago
ik, thats whats caling the method sec
public async Task GiveawayTimerAction(Database.Models.Giveaways r, IGuild inputguild = null, ITextChannel inputchannel = null)
{
var dclient = client as IDiscordClient;
var guild = inputguild ?? await dclient.GetGuildAsync(r.ServerId);
if (guild is null)
return;

var channel = inputchannel ?? await guild.GetTextChannelAsync(r.ChannelId);
if (channel is null)
return;
IUserMessage ch;
try
{
if (await channel.GetMessageAsync(r.MessageId).ConfigureAwait(false) is not
IUserMessage ch1)
{
return;
}

ch = ch1;
}
catch
{
return;
}

var prefix = await guildSettings.GetPrefix(guild.Id).ConfigureAwait(false);
public async Task GiveawayTimerAction(Database.Models.Giveaways r, IGuild inputguild = null, ITextChannel inputchannel = null)
{
var dclient = client as IDiscordClient;
var guild = inputguild ?? await dclient.GetGuildAsync(r.ServerId);
if (guild is null)
return;

var channel = inputchannel ?? await guild.GetTextChannelAsync(r.ChannelId);
if (channel is null)
return;
IUserMessage ch;
try
{
if (await channel.GetMessageAsync(r.MessageId).ConfigureAwait(false) is not
IUserMessage ch1)
{
return;
}

ch = ch1;
}
catch
{
return;
}

var prefix = await guildSettings.GetPrefix(guild.Id).ConfigureAwait(false);
this all stems from a previous jank issue lol
blinkbat
blinkbat272d ago
it could be hitting any of those returns
SylveonDeko
SylveonDeko272d ago
onefuture
onefuture272d ago
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var gway = uow.Giveaways.GiveawaysForGuild(ctx.Guild.Id).FirstOrDefault(x => x.MessageId == messageid);

if (gway == null)
{
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!").ConfigureAwait(false);
return;
}

if (gway.Ended == 1)
{
await ctx.Channel.SendErrorAsync(
$"This giveaway has already ended! Please use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!").ConfigureAwait(false);
return;
}

var channel = await Context.Guild.GetTextChannelAsync(gway.ChannelId);
if (channel == null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!").ConfigureAwait(false);
return;
}

await Service.GiveawayTimerAction(gway, channel.Guild, channel).ConfigureAwait(false);
await ctx.Channel.SendConfirmAsync("Giveaway ended!").ConfigureAwait(false);
}
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var gway = uow.Giveaways.GiveawaysForGuild(ctx.Guild.Id).FirstOrDefault(x => x.MessageId == messageid);

if (gway == null)
{
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!").ConfigureAwait(false);
return;
}

if (gway.Ended == 1)
{
await ctx.Channel.SendErrorAsync(
$"This giveaway has already ended! Please use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!").ConfigureAwait(false);
return;
}

var channel = await Context.Guild.GetTextChannelAsync(gway.ChannelId);
if (channel == null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!").ConfigureAwait(false);
return;
}

await Service.GiveawayTimerAction(gway, channel.Guild, channel).ConfigureAwait(false);
await ctx.Channel.SendConfirmAsync("Giveaway ended!").ConfigureAwait(false);
}
SylveonDeko
SylveonDeko272d ago
where for some reason channel was null
S-IERRA
S-IERRA272d ago
yes like i said
SylveonDeko
SylveonDeko272d ago
but that was only socket
S-IERRA
S-IERRA272d ago
it could be failing to fetch it as a fallback value
SylveonDeko
SylveonDeko272d ago
rest returns it fine
S-IERRA
S-IERRA272d ago
missing intent most likley
SylveonDeko
SylveonDeko272d ago
nope
S-IERRA
S-IERRA272d ago
weird
SylveonDeko
SylveonDeko272d ago
all intents on and configured
blinkbat
blinkbat272d ago
debug after that line see the value of channel
SylveonDeko
SylveonDeko272d ago
that code is long changed, channel is null becausse its null for some reason despite not being null in the calling method
blinkbat
blinkbat272d ago
why would you send old code
SylveonDeko
SylveonDeko272d ago
^
blinkbat
blinkbat272d ago
do you have a bug or not
SylveonDeko
SylveonDeko272d ago
yes
onefuture
onefuture272d ago
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var giveaway = uow.Giveaways.GiveawaysForGuild(ctx.Guild.Id).FirstOrDefault(x => x.MessageId == messageid);

if (giveaway == null)
{
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!");
return;
}

if (giveaway.Ended == 1)
{
await ctx.Channel.SendErrorAsync($"This giveaway has already ended! Use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!");
return;
}

var channel = await Context.Guild.GetTextChannelAsync(giveaway.ChannelId);
if (channel == null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!");
return;
}

await Service.GiveawayTimerAction(giveaway, channel.Guild, channel);
await ctx.Channel.SendConfirmAsync("Giveaway ended!");
}
[Cmd, Aliases, RequireContext(ContextType.Guild), UserPerm(GuildPermission.ManageMessages)]
public async Task GEnd(ulong messageid)
{
await using var uow = db.GetDbContext();
var giveaway = uow.Giveaways.GiveawaysForGuild(ctx.Guild.Id).FirstOrDefault(x => x.MessageId == messageid);

if (giveaway == null)
{
await ctx.Channel.SendErrorAsync("No Giveaway with that message ID exists! Please try again!");
return;
}

if (giveaway.Ended == 1)
{
await ctx.Channel.SendErrorAsync($"This giveaway has already ended! Use `{await guildSettings.GetPrefix(ctx.Guild)}greroll {messageid}` to reroll!");
return;
}

var channel = await Context.Guild.GetTextChannelAsync(giveaway.ChannelId);
if (channel == null)
{
await ctx.Channel.SendErrorAsync("Giveaway channel not found!");
return;
}

await Service.GiveawayTimerAction(giveaway, channel.Guild, channel);
await ctx.Channel.SendConfirmAsync("Giveaway ended!");
}
blinkbat
blinkbat272d ago
can you like stop maybe
onefuture
onefuture272d ago
...
Jimmacle
Jimmacle272d ago
just report and move on
onefuture
onefuture272d ago
im sending better code
SylveonDeko
SylveonDeko272d ago
channel is NOT null here so im confused af
S-IERRA
S-IERRA272d ago
@new FuckPremiumBots() im thinking it could be race contition related
SylveonDeko
SylveonDeko272d ago
oh boy thats fun
S-IERRA
S-IERRA272d ago
because if ur doing an async operation then its failing to fetch it in time then its ffailing on the if statement
SylveonDeko
SylveonDeko272d ago
definitely possible
S-IERRA
S-IERRA272d ago
because when you run it thru debugger it worked
SylveonDeko
SylveonDeko272d ago
lovely what could the race condition be tho
S-IERRA
S-IERRA272d ago
it wouldnt make sense tho cuz ur awaiting it
SylveonDeko
SylveonDeko272d ago
the async methods dont run since i give the values and they arent null
S-IERRA
S-IERRA272d ago
S-IERRA
S-IERRA272d ago
on debugger can u check
SylveonDeko
SylveonDeko272d ago
yeah
S-IERRA
S-IERRA272d ago
wait u did nvm
SylveonDeko
SylveonDeko272d ago
thats why channel isnt null im losing braincells trying to figure this out lmao
S-IERRA
S-IERRA272d ago
write ITextChannel?
S-IERRA
S-IERRA272d ago
even with IGuild
SylveonDeko
SylveonDeko272d ago
yes
S-IERRA
S-IERRA272d ago
im pretty sure thats the issue
SylveonDeko
SylveonDeko272d ago
why would that be an issue Thonk
S-IERRA
S-IERRA272d ago
isnt nullable and over c# 8 thats an issue
SylveonDeko
SylveonDeko272d ago
it is Thonk you mean put a ?
S-IERRA
S-IERRA272d ago
yes ITextChannel? inputChannel = null
SylveonDeko
SylveonDeko272d ago
in which case it shouldnt matter because i do the same with my commands and it doesnt have an issue
S-IERRA
S-IERRA272d ago
just try it see what it does
SylveonDeko
SylveonDeko272d ago
alr
S-IERRA
S-IERRA272d ago
if not what u can also do there should be a nullable over ride method HasValue when you make it nullable so set it to what i said above and then check if(inputChannel.HasValue)
SylveonDeko
SylveonDeko272d ago
SylveonDeko
SylveonDeko272d ago
same with inputchannel
S-IERRA
S-IERRA272d ago
ignore that then but ud put that on the if statement
SylveonDeko
SylveonDeko272d ago
running it with ? still makes it stop
S-IERRA
S-IERRA272d ago
not the assignment
SylveonDeko
SylveonDeko272d ago
oh
S-IERRA
S-IERRA272d ago
1s
SylveonDeko
SylveonDeko272d ago
wait Thonk
S-IERRA
S-IERRA272d ago
?
SylveonDeko
SylveonDeko272d ago
nvm
S-IERRA
S-IERRA272d ago
r u sure its failing at that point w/o debugger
SylveonDeko
SylveonDeko272d ago
yes i can add console logs 🤷‍♂️
S-IERRA
S-IERRA272d ago
yes, would be good i feel like they might have over ridden the is operator and its doing some more bs
SylveonDeko
SylveonDeko272d ago
lets see
onefuture
onefuture272d ago
Blud is discord support for FREE
SylveonDeko
SylveonDeko272d ago
wat.
SylveonDeko
SylveonDeko272d ago
this makes no fucking sense
S-IERRA
S-IERRA272d ago
yh was right then its failing somewhere down the line
SylveonDeko
SylveonDeko272d ago
but then
SylveonDeko
SylveonDeko272d ago
this would have stopped it
SylveonDeko
SylveonDeko272d ago
i put a debug marker there too
Patrick
Patrick272d ago
!ban @1ftr trolling
SylveonDeko
SylveonDeko272d ago
wat.
S-IERRA
S-IERRA272d ago
try putting logs line by line tbf, then you ll haev a betetr idea
SylveonDeko
SylveonDeko272d ago
S-IERRA
S-IERRA272d ago
ch wouldnt error thats just assignment its just null
SylveonDeko
SylveonDeko272d ago
ofc it wouldnt but it would at least stop right?
S-IERRA
S-IERRA272d ago
nah is just an empty assignment no reason to stop
SylveonDeko
SylveonDeko272d ago
S-IERRA
S-IERRA272d ago
press f11
SylveonDeko
SylveonDeko272d ago
ok so it turns out im just a moron got it
S-IERRA
S-IERRA272d ago
prolly this
SylveonDeko
SylveonDeko272d ago
weird
S-IERRA
S-IERRA272d ago
idk what this method does but could be this?
S-IERRA
S-IERRA272d ago
but ye it ssomewhere there
SylveonDeko
SylveonDeko272d ago
heard this and have been using it ever since: To avoid these problems, we can use ConfigureAwait(false) to tell await not to capture and resume on the current context, but instead resume on any available thread. This can improve performance, scalability and avoid deadlocks in some scenarios
Angius
Angius272d ago
It's only really useful in old .NET Framework and in libraries
SylveonDeko
SylveonDeko272d ago
ah got it
Angius
Angius272d ago
I don't think it does anything useful since Core Try yeeting it all and see what happens
SylveonDeko
SylveonDeko272d ago
trying
SylveonDeko
SylveonDeko272d ago
yknow im a massive moron sometimes
SylveonDeko
SylveonDeko272d ago
ok yeah it doesnt fail there
S-IERRA
S-IERRA272d ago
so far so good btw just for future reference try doing what i do
SylveonDeko
SylveonDeko272d ago
?
S-IERRA
S-IERRA272d ago
public async Task<GenericResponse<NumixListing>> ModifyListing(Guid listingId, ModifyListingRequest request)
{
_logger.Information($"ListingImplementation:ModifyListing - Start (ListingId: {listingId})");

await using var context = ContextFactory.CreateDbContext();
if (await context.Listings.FirstOrDefaultAsync() is not { } numixListing)
{
_logger.Information($"ListingImplementation:ModifyListing - Listing not found (ListingId: {listingId})");
return new GenericResponse<NumixListing>(null, "Listing not found");
}
public async Task<GenericResponse<NumixListing>> ModifyListing(Guid listingId, ModifyListingRequest request)
{
_logger.Information($"ListingImplementation:ModifyListing - Start (ListingId: {listingId})");

await using var context = ContextFactory.CreateDbContext();
if (await context.Listings.FirstOrDefaultAsync() is not { } numixListing)
{
_logger.Information($"ListingImplementation:ModifyListing - Listing not found (ListingId: {listingId})");
return new GenericResponse<NumixListing>(null, "Listing not found");
}
sec i ll give context
[HttpPatch("{listingId:guid}")]
public async Task<IActionResult> ModifyListing(Guid listingId, ModifyListingRequest request)
{
GenericResponse<NumixListing> genericResponse = await _listingService.ModifyListing(listingId, request);
if (genericResponse.ErrorMessage is not null)
return Problem(genericResponse.ErrorMessage);

await _cachedListingService.UpdateCache(genericResponse.Model!);

return Ok();
}
[HttpPatch("{listingId:guid}")]
public async Task<IActionResult> ModifyListing(Guid listingId, ModifyListingRequest request)
{
GenericResponse<NumixListing> genericResponse = await _listingService.ModifyListing(listingId, request);
if (genericResponse.ErrorMessage is not null)
return Problem(genericResponse.ErrorMessage);

await _cachedListingService.UpdateCache(genericResponse.Model!);

return Ok();
}
so when u have an error dont just do an empty return try to atleast log it makes ur life x1000 easier
SylveonDeko
SylveonDeko272d ago
yeah also i just realized the dumb i did lel
S-IERRA
S-IERRA272d ago
what was wrong
SylveonDeko
SylveonDeko272d ago
before i fixed it, this was just checkking is null
SylveonDeko
SylveonDeko272d ago
and of course, it was just eeveefacepalm see if that fixes it lel it did not, bug hunting time
SylveonDeko
SylveonDeko272d ago
and fixed it
SylveonDeko
SylveonDeko272d ago
kek thx guys for guiding me through my stupidity its been a Brainless day today
S-IERRA
S-IERRA272d ago
nws nws happens currently im loosing my shit too over a ticket below you so
SylveonDeko
SylveonDeko272d ago
lolol good luck
jcotton42
jcotton42272d ago
it still does the same thing it doesn't use the active sync context to schedule the continuation for example, in a GUI app
// on UI thread
await Task.Delay(250);
// still on UI thread, b/c the sync context installed by the framework put us here
await Task.Delay(250).ConfigureAwait(false);
// no more sync context, default scheduler used
// we're now on the thread pool
// on UI thread
await Task.Delay(250);
// still on UI thread, b/c the sync context installed by the framework put us here
await Task.Delay(250).ConfigureAwait(false);
// no more sync context, default scheduler used
// we're now on the thread pool
@ZZZZZZZZZZZZZZZZZZZZZZZZZ in the case of a discord bot, you probably don't have a sync context, so it won't affect anything either way
Angius
Angius272d ago
Didn't something change about it with Core?
jcotton42
jcotton42272d ago
Stephen Toub - MSFT
.NET Blog
ConfigureAwait FAQ - .NET Blog
.NET added async/await to the languages and libraries over seven years ago. In that time, it’s caught on like wildfire, not only across the .NET ecosystem, but also being replicated in a myriad of other languages and frameworks. It’s also seen a ton of improvements in .NET,
jcotton42
jcotton42272d ago
not how it works fundamentally
Accord
Accord270d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ ASP.NET always validates invalid JWTI have a custom configuration for Asp.net where the JWT Token is stored in an http-only cookie, beca❔ Class with Func<> and class initializersIf I define a class with members to be passed to known create type functions how do I set the Func<>✅ .NET MVC - AJAX BEGINFORM UpdateTargetId not workingHi, I want to update my table after insert and update with ajax beginform. I give updatetargetid the[WPF] Creating grouped content in XAML to hide.Hi, Is it possible to group multiple UI elements into a group, and then hide the entire group, whil❔ Blazor for a C# beginner?Essentially, i wanted to get into web dev, and found out that you don't actually need to learn js. IProblemDetails and FluentValidationIm having issues returning/throwing a custom exception made with ProblemDetails. Im using FluentVali❔ C# Beginner BookDoes anybody know any good books worth reading about c# for begginers? primarily focused on WPF, butWPF can't access to ElementName with ControlTemplatehttps://paste.mod.gg/njerxhgbdgzp/0Namespace needed or not?Hello. I am a python coder (still quite new) who wants to branch out to C# as it is used for Unity aUnclear class creationhow would i go about resolving this error? This is what im getting: ```Error while compiling: Island❔ Creating A Share Button in avaloniaI have a button ```xml <Button Grid.Column="2" Command="{Binding $parent[Window].DataContext.ShareEnCustom MSBuild task fails to load `System.Runtime`Hi, I'm making a custom MSBuild task that needs to load images and I was using `ImageSharp` for that❔ Cannot convert lambda expression to type 'Activity' because it is not a delegate type errorSo I want to check if List contains element with todays date but tis error occurs: `CS1660 Canno❔ Need help implementing a toolboxWhat's a good way to implement something like this? Currently I have some services, all of which imp❔ ASP .NET Core Controller Default Route IssueI have a controller (TestController) with an Index action method. The url I'm using is "localhost:8❔ Hiya i am new to C# i am having problems with return method``` static void Main(string[] args) { Console.WriteLine("Hello World!"); int ✅ How to return List from RestClient?Hi, I am making rest client for my application using RestSharp (like their twitter client in guide <❔ is there any moderate projects to read and study?I built a simple website after learning web dev but I lost my direction to improve. I want to study ❔ This issue cannot be resolved for several hours. HELP ME...The problem is the character on the red mark in the picture below. This is the source code where the❔ Dynamically adding xaml code from 1 page to another pages xaml codeI'm working on a simple barbershop application that let's people make appointments etc. At the momen