Drn 2 lat temu
rodzic
commit
f8750ab757
5 zmienionych plików z 9 dodań i 13 usunięć
  1. 2 3
      config.go
  2. 4 4
      downloads.go
  3. 1 2
      handlers.go
  4. 1 2
      history.go
  5. 1 2
      main.go

+ 2 - 3
config.go

@@ -3,7 +3,6 @@ package main
 import (
 	"bufio"
 	"encoding/json"
-	"io/ioutil"
 	"log"
 	"os"
 	"runtime"
@@ -408,7 +407,7 @@ func loadConfig() error {
 	// .
 	log.Println(lg("Settings", "loadConfig", color.YellowString, "Loading from \"%s\"...", configFile))
 	// Load settings
-	configContent, err := ioutil.ReadFile(configFile)
+	configContent, err := os.ReadFile(configFile)
 	if err != nil {
 		log.Println(lg("Settings", "loadConfig", color.HiRedString, "Failed to open file...\t%s", err))
 		createConfig()
@@ -747,7 +746,7 @@ func createConfig() {
 	if err != nil {
 		log.Println(lg("Settings", "create", color.HiRedString, "Failed to format new settings...\t%s", err))
 	} else {
-		err := ioutil.WriteFile(configFile, defaultJSON, 0644)
+		err := os.WriteFile(configFile, defaultJSON, 0644)
 		if err != nil {
 			log.Println(lg("Settings", "create", color.HiRedString, "Failed to save new settings file...\t%s", err))
 		} else {

+ 4 - 4
downloads.go

@@ -3,8 +3,8 @@ package main
 import (
 	"bytes"
 	"fmt"
+	"io"
 	"io/fs"
-	"io/ioutil"
 	"log"
 	"math/rand"
 	"mime"
@@ -534,7 +534,7 @@ func (download downloadRequestStruct) handleDownload() (downloadStatusStruct, in
 					logPath += ".txt"
 				}
 				// Read
-				currentLog, err := ioutil.ReadFile(logPath)
+				currentLog, err := os.ReadFile(logPath)
 				currentLogS := ""
 				if err == nil {
 					currentLogS = string(currentLog)
@@ -667,7 +667,7 @@ func (download downloadRequestStruct) tryDownload() (downloadStatusStruct, int64
 		defer response.Body.Close()
 
 		// Read
-		bodyOfResp, err := ioutil.ReadAll(response.Body)
+		bodyOfResp, err := io.ReadAll(response.Body)
 		if err != nil {
 			log.Println(lg("Download", "", color.HiRedString,
 				"Could not read response from \"%s\": %s",
@@ -984,7 +984,7 @@ func (download downloadRequestStruct) tryDownload() (downloadStatusStruct, int64
 
 		// Write
 		if *channelConfig.Save {
-			if err = ioutil.WriteFile(completePath, bodyOfResp, 0644); err != nil {
+			if err = os.WriteFile(completePath, bodyOfResp, 0644); err != nil {
 				log.Println(lg("Download", "", color.HiRedString,
 					"Error while writing file to disk \"%s\": %s", download.InputURL, err))
 				return mDownloadStatus(downloadFailedWritingFile, err), 0

+ 1 - 2
handlers.go

@@ -2,7 +2,6 @@ package main
 
 import (
 	"fmt"
-	"io/ioutil"
 	"log"
 	"os"
 	"strings"
@@ -132,7 +131,7 @@ func handleMessage(m *discordgo.Message, edited bool, history bool) (int64, int6
 					logPath += ".txt"
 				}
 				// Read
-				currentLog, err := ioutil.ReadFile(logPath)
+				currentLog, err := os.ReadFile(logPath)
 				currentLogS := ""
 				if err == nil {
 					currentLogS = string(currentLog)

+ 1 - 2
history.go

@@ -2,7 +2,6 @@ package main
 
 import (
 	"fmt"
-	"io/ioutil"
 	"log"
 	"os"
 	"strconv"
@@ -135,7 +134,7 @@ func handleHistory(commandingMessage *discordgo.Message, subjectChannelID string
 
 	//#region Cache Files
 	openHistoryCache := func(dirpath string, output *string) {
-		if f, err := ioutil.ReadFile(dirpath + string(os.PathSeparator) + subjectChannelID); err == nil {
+		if f, err := os.ReadFile(dirpath + string(os.PathSeparator) + subjectChannelID); err == nil {
 			*output = string(f)
 			if !autorun && config.Debug {
 				log.Println(lg("Debug", "History", color.YellowString,

+ 1 - 2
main.go

@@ -3,7 +3,6 @@ package main
 import (
 	"encoding/json"
 	"fmt"
-	"io/ioutil"
 	"log"
 	"net/url"
 	"os"
@@ -397,7 +396,7 @@ func main() {
 	if err != nil {
 		log.Println(lg("Constants", "", color.HiRedString, "Failed to format constants...\t%s", err))
 	} else {
-		err := ioutil.WriteFile(constantsPath, newJson, 0644)
+		err := os.WriteFile(constantsPath, newJson, 0644)
 		if err != nil {
 			log.Println(lg("Constants", "", color.HiRedString, "Failed to save new constants file...\t%s", err))
 		}