Skip to content

Commit 99f7e25

Browse files
committed
still trying to fix the discord file send
1 parent 2ea5bf1 commit 99f7e25

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

Framework/Utils/RandomUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static string GenerateRandomString(long requiredLength)
4747
var result = "";
4848
while (result.Length < requiredLength)
4949
{
50-
var bytes = new byte[1024];
50+
var len = Math.Min(1024, requiredLength - result.Length);
51+
var bytes = new byte[len];
5152
random.NextBytes(bytes);
5253
result += string.Join("", bytes.Select(b => b.ToString()));
5354
}

Tools/BiblioTech/Commands/CheckResponseHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public async Task GiveCidToUser(string cid)
3434

3535
public async Task GiveDataFileToUser(string fileContent)
3636
{
37-
await context.Followup("Please download the attached file. Upload it to your Codex node, " +
37+
await context.SendFile(fileContent, "Please download the attached file. Upload it to your Codex node, " +
3838
"then provide the CID as argument to this command.");
39-
40-
await context.SendFile(fileContent);
4139
}
4240

4341
public async Task GiveRoleReward()

Tools/BiblioTech/Options/CommandContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ await Command.ModifyOriginalResponseAsync(m =>
4949
}
5050
}
5151

52-
public async Task SendFile(string fileContent)
52+
public async Task SendFile(string fileContent, string message)
5353
{
5454
var stream = new MemoryStream();
5555
var writer = new StreamWriter(stream);
5656
writer.Write(fileContent);
5757

58-
await Command.RespondWithFileAsync(stream, "CheckFile.txt", ephemeral: true);
58+
await Command.RespondWithFileAsync(stream, "CheckFile.txt", text: message, ephemeral: true);
5959

6060
// Detached task for cleaning up the stream resources.
6161
_ = Task.Run(() =>

0 commit comments

Comments
 (0)