[BUG] Command not executing everything
See original GitHub issueHello, So it happened to me few times that when I make command and execute it, only few lines are executing and function ends(goes back where it was executed). Please help as I can’t do anything, because of it.
REMINDER! SENT CODE SHOULD NOT BE COPIED AS I SPEND SOME TIME MAKING THIS GIVEAWAY COMMAND AND I DO NOT WANT SOMEONE COPY ME
Command Trigger:
public async static Task CommandExecuted(SocketSlashCommand command)
{
var currentTime = DateTime.Now;
Console.WriteLine($"[{currentTime:G}] Command '{command.Data.Name}' has been executed");
switch (command.Data.Name)
{
case "feedback":
await FeedbackCommand(command);
break;
case "botinfo":
await BotInfoCommand(command);
break;
case "announce":
await AnnounceCommand(command);
break;
case "lockdown":
await LockdownCommand(command);
break;
case "kick":
await KickCommand(command);
break;
case "ban":
await BanCommand(command);
break;
case "tip":
await TipCommand(command);
break;
case "createproductinfo":
await CreateProductInfoCommand(command);
break;
case "wipe-data":
await WipeDataCommand(command);
break;
case "tax":
await TaxCommand(command);
break;
case "giveaway":
await GiveawayCommand(command);
break;
}
}
Giveaway Command:
private async static Task GiveawayCommand(SocketSlashCommand command)
{
var fieldName = command.Data.Options.First().Name;
if(fieldName == "start")
{
string prize = (string)command.Data.Options.First().Options.ToArray()[0].Value;
string time = (string)command.Data.Options.First().Options.ToArray()[1].Value;
int winnersCount = (int)command.Data.Options.First().Options.ToArray()[2].Value;
string req = (string)command.Data.Options.First().Options.ToArray()[4].Value;
ITextChannel chnl = (ITextChannel)command.Data.Options.First().Options.ToArray()[3].Value;
req = req.Replace(null, "N/A");
long timeConv = StringToDate(time);
long milTimeConv = timeConv * 1000;
int intMilTimeConv = (int)timeConv * 1000;
var embed = new EmbedBuilder()
.WithTitle(prize)
.WithColor(Color.DarkBlue)
.WithFooter("Hub Manager | By HAHOOS#5942", iconUrl: "https://cdn.discordapp.com/attachments/919590140790321206/932654573829628025/Hub_Manager_Icon_v2.png")
.WithDescription($"New giveaway has been started! React to join.{Environment.NewLine}{Environment.NewLine}**Host:**{command.User.Mention}{Environment.NewLine}**Ends in: <t:{timeConv + DateTimeOffset.Now.ToUnixTimeSeconds()}:r>**{Environment.NewLine}{Environment.NewLine}**REQUIREMENTS:**{Environment.NewLine}{req}");
IMessage msg = await chnl.SendMessageAsync("<:Giveaway:947065168368644136> **Giveaway has been started!** <:Giveaway:947065168368644136>", embed: embed.Build());
IEmote emoji1 = new Emoji("🎉");
await msg.AddReactionAsync(emoji1);
await Task.Delay(intMilTimeConv);
var peopleReacted = msg.GetReactionUsersAsync(emoji1, 500).FlattenAsync<IUser>().Result.ToArray();
Random r = new Random();
List<IUser> winners = new();
for (int i = 0; i < winnersCount; i++)
{
winners.Add(peopleReacted[r.Next(0, peopleReacted.Length)]);
}
string mentionText = "";
foreach(var user in winners)
{
mentionText += user.Mention + " ";
}
await chnl.SendMessageAsync($"<:Giveaway:947065168368644136> {mentionText}has won the giveaway! <:Giveaway:947065168368644136>");
}else if(fieldName == "reroll")
{
IEmote emoji1 = new Emoji("🎉");
ulong id = (ulong)command.Data.Options.First().Options.ToArray()[0].Value;
var chnlGuild = command.Channel as IGuildChannel;
var guild = chnlGuild.Guild;
IMessage msg = command.Channel.GetMessageAsync(id).Result;
var peopleReacted = msg.GetReactionUsersAsync(emoji1, 500).FlattenAsync<IUser>().Result.ToArray();
Random r = new Random();
await command.RespondAsync($"**REROLL** <:Giveaway:947065168368644136> {peopleReacted[r.Next(0, peopleReacted.Length)].Mention} has won the giveaway! <:Giveaway:947065168368644136>");
}
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
bash - script not executing all the way through
Everything works fine when launching it from terminal, but whenever i try to auto launch it at startup, it gets killed instantly. The...
Read more >windows - Bash not executing from command line
Go to Properties, and then the Terminal tab. Uncheck Use separate foreground and 'Use separate backround' Now type bash in cmd and it...
Read more >Command runs from the shell, but doesn't run from a script.sh
Almost certainly this is happening because the shell you are using to run the script is not the same as your interactive shell....
Read more >[BUG] Can't run shell commands in drun mode · Issue #1187
Under "drun", the manpage says: Pressing the accept-custom binding (control-enter or shift-enter) with custom input (no entry matching) will run ...
Read more >Some commands not executing in shell-script when using ...
1 Answer. Finally, I found a solution. The point of problem isn't permission but in a different shell environment than cron is executing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If the command is successfully called, that’s all the lib is responsible for. The contents of the command method is up to you. If the code is stopping at a specific point during execution of the command, then an exception is being thrown. Start by capturing and reviewing that exception in order to come up with a solution.
@HAHOOS Did you find a solution to your issue?