Giter Club home page Giter Club logo

discord.net-example's People

Contributors

aux avatar descuddlebat avatar foxbot avatar haydencrain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord.net-example's Issues

What happend

„Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..”

No service for type 'CommandHandler'

Run into System.InvalidOperationException while trying to run code.
Program breaks a provider.GetRequiredService<CommandHandler>();

Solution:
Add .AddSingleton<CommandHandler>() to ConfigureServices

Solution won't run

image
I get this error every time I try to run the program from visual studio. Does anyone know why?

Config URI Error

Hey,

Unsure if I'm doing something wrong or I am missing something, I cannot get the app to run.
Cloned it and put my token in the config however VS will not parse the YAML file no matter what I do to it.

Here's a log of the error;

System.FormatException
  HResult=0x80131537
  Message=Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..
  Source=Microsoft.Extensions.Configuration.FileExtensions
  StackTrace:
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Example.Startup..ctor(String[] args) in C:\Users\Joey\Downloads\Discord.Net-Example-2.0\Discord.Net-Example-2.0\src\Startup.cs:line 20
   at Example.Startup.<RunAsync>d__4.MoveNext() in C:\Users\Joey\Downloads\Discord.Net-Example-2.0\Discord.Net-Example-2.0\src\Startup.cs:line 25
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Example.Program.<Main>(String[] args)

Inner Exception 1:
SyntaxErrorException: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI.

Any help maybe?

Get commands

Hello Auxes,

If you could make a module displaying how to properly get commands and display information about them like their aliases and such that would be awesome.

Thanks,

System.FormatException: 'Could not parse the YAML file.'

Hi there,

I just downloaded your example and tried running it, but it breaks with the following error message:

System.FormatException: 'Could not parse the YAML file: (Line: 1, Col: 9, Idx: 8) - (Line: 1, Col: 10, Idx: 9): While parsing a tag, did not find expected tag URI..'

The contents of the _config.yml file are:

prefix: !
tokens:
    discord: [my bot's token]

Nothing else was changed by me in the code.
Any clues on how to fix this?

Thanks!
~Feng

i got error ObjectNotFound: User not found.

i got error ObjectNotFound: User not found. when i try to start command
this is my command code 👍 what I do bad

[Command("info")]
        [Summary("sprawdza info")]
        [RequireUserPermission(GuildPermission.Administrator)]
        public async Task Info(SocketGuildUser user)
        {
            int maxwarn = 3;
            if (File.Exists($"{Context.Guild.Id}maxwarn.XD"))
            {
                using (StreamReader sr = new StreamReader($"{Context.Guild.Id}maxwarn.XD"))
                {
                    maxwarn = int.Parse(sr.ReadLine());
                }
            }
            int warny = 0;
            if (File.Exists($"{user}warn{Context.Guild.Id}.XD"))
            {
                using (StreamReader sr = new StreamReader($"{user}warn{Context.Guild.Id}.XD"))
                {
                    warny = int.Parse(sr.ReadLine());
                }
            }
            await ReplyAsync($"użytkownik {user} ma {warny} warny ⚠\npamiętaj że po {maxwarn} warnach⚠ jest ban 🚫\nwięc możesz dostać jeszcze {maxwarn-warny} warny⚠");
        }

and when I start a bot and write the first command I got the error Object reference not set to an instance of an object
after click continue In visual studio it's work normal
what I do bad
please help
I work on this example

UnknownCommand: Unknown command.

This happens for all commands and I've copied and pasted the code into my project and am wondering where I should look in the code to solve this issue. Of course, I did read where you have the error being output into the Discord channel but really that didn't help me know where it's having an issue getting the command modules.

Of course, since I don't know where the issue is, please tell me what code I should share to resolve this.

Thanks

Random is not thread safe.

The singleton should be a ThreadLocal<Random> or maybe a Random with a lock mechanism. Using only one instance on multiple threads will result in getting 0 from every Random call, has happened to me in the past.

HelpModule Gives Me an Error

System.InvalidOperationException HResult=0x80131509 Message=Failed to create "Example.Modules.HelpModule", dependency "IConfigurationRoot" was not found. Source=Discord.Net.Commands StackTrace: at Discord.Commands.ReflectionUtils.GetMember(CommandService commands, IServiceProvider services, Type memberType, TypeInfo ownerType) at Discord.Commands.ReflectionUtils.<>c__DisplayClass2_01.b__0(IServiceProvider services)
at Discord.Commands.ReflectionUtils.CreateObject[T](TypeInfo typeInfo, CommandService commands, IServiceProvider services)
at Discord.Commands.Builders.ModuleBuilder.BuildImpl(CommandService service, IServiceProvider services, ModuleInfo parent)
at Discord.Commands.ModuleClassBuilder.d__3.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Discord.Commands.CommandService.d__35.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at DbotTest.Program.d__6.MoveNext() in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 56
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DbotTest.Program.d__4.MoveNext() in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 38
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DbotTest.Program.Main(String[] args) in C:\Users\Matthew\source\repos\DbotTest\Program.cs:line 18

This exception was originally thrown at this call stack:
Discord.Commands.ReflectionUtils.GetMember(Discord.Commands.CommandService, System.IServiceProvider, System.Type, System.Reflection.TypeInfo)
Discord.Commands.Builders.ModuleBuilder.BuildImpl(Discord.Commands.CommandService, System.IServiceProvider, Discord.Commands.ModuleInfo)
Discord.Commands.ModuleClassBuilder.BuildAsync(System.Collections.Generic.IEnumerable<System.Reflection.TypeInfo>, Discord.Commands.CommandService, System.IServiceProvider)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
Discord.Commands.CommandService.AddModulesAsync(System.Reflection.Assembly, System.IServiceProvider)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
...
[Call Stack Truncated]
`

I guess this is what I get for doing a "copypasta". All I did was that I made a new cSharp class file and it would scream this at me every time I try to run the bot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.